seed_dump
seed_dump copied to clipboard
Problem with hashes stored in Text field.
If I export a table that has hashes stored in text fields, I get things like:
[1503, 7179, "Punch", "update", {"punched_out_at"=>[nil, 2016-05-25 17:00:00 UTC], "updated_at"=>[2016-05-25 17:40:35 UTC, 2016-05-25 17:40:41 UTC]}],
[1503, 7180, "Punch", "update", {"punched_out_at"=>[nil, 2016-05-25 17:30:00 UTC], "updated_at"=>[2016-05-25 17:40:39 UTC, 2016-05-25 17:40:45 UTC]}],
[1503, 7181, "Punch", "update", {"punched_out_at"=>[nil, 2016-05-25 17:00:00 UTC], "updated_at"=>[2016-05-25 17:40:49 UTC, 2016-05-25 17:41:04 UTC]}],
[4195, 7166, "Punch", "update", {"punched_in_at"=>[2016-05-25 13:18:00 UTC, 2016-05-25 13:30:00 UTC], "updated_at"=>[2016-05-24 22:37:17 UTC, 2016-05-25 21:52:34 UTC]}],
[4195, 7187, "Punch", "update", {"punched_in_at"=>[2016-05-25 21:53:00 UTC, 2016-05-25 14:30:00 UTC], "updated_at"=>[2016-05-25 21:53:51 UTC, 2016-05-25 21:54:52 UTC]}],
[4664, 7188, "Punch", "update", {"punched_out_at"=>[nil, 2016-05-26 18:07:00 UTC], "updated_at"=>[2016-05-26 19:38:45 UTC, 2016-05-26 19:39:02 UTC]}],
[4664, 7189, "Punch", "update", {"punched_out_at"=>[nil, 2016-05-26 18:04:00 UTC], "updated_at"=>[2016-05-26 19:38:49 UTC, 2016-05-26 19:39:09 UTC]}],
[4664, 7190, "Punch", "update", {"punched_out_at"=>[nil, 2016-05-26 18:08:00 UTC], "updated_at"=>[2016-05-26 19:38:58 UTC, 2016-05-26 19:39:16 UTC]}],
[nil, 7194, "Punch", "update", {"punched_out_at"=>[nil, 2016-05-26 20:26:00 UTC], "updated_at"=>[2016-05-26 19:39:43 UTC, 2016-05-26 20:26:27 UTC]}],
[4664, 7192, "Punch", "update", {"punched_in_at"=>[2016-05-26 15:05:00 UTC, 2016-05-26 16:00:00 UTC], "updated_at"=>[2016-05-26 19:39:31 UTC, 2016-05-26 20:31:19 UTC]}],
[3222, 7198, "Punch", "update", {"punched_out_at"=>[nil, 2016-05-27 16:02:00 UTC], "updated_at"=>[2016-05-27 18:45:04 UTC, 2016-05-27 18:45:07 UTC]}],
[3222, 7198, "Punch", "update", {"punched_in_at"=>[2016-05-27 12:58:00 UTC, 2016-05-27 11:58:00 UTC], "updated_at"=>[2016-05-27 18:45:07 UTC, 2016-05-27 18:45:10 UTC]}],
[3219, 7160, "Punch", "update", {"punched_out_at"=>[nil, 2016-05-24 22:00:00 UTC], "updated_at"=>[2016-05-24 20:29:49 UTC, 2016-05-27 18:48:20 UTC]}]
The last hash at the end comes from a text field, and can't be loaded back to a text field this way..
Ok, understood the problem is when the field is serialized. It would make sense the seed_dump gem would use the attributes_before_type_cast in order to get the database values before type casts. Does that make sense?
Going to create a branch with a fix to this issue.
see https://github.com/rroblak/seed_dump/pull/106