rroblak/seed_dump

Duplicated records issue

pierreferry opened this issue · 1 comments

I encountered an issue with one table of my database : duplicates.
For example if the table was 100 entities, i had 100 entities to import but with duplicates, meaning there were some entities lost in the process.
After investigation i realised those entities were duplicated because of the order method wasn't working, breaking in the same time the batching algorithm.

That's why i forked the project and replaced line 8 in enumeration.rb :
records.order("#{records.quoted_table_name}.#{records.quoted_primary_key} ASC")
by
records = records.order(records.primary_key => :asc)

I hope this helps someone

This helped me, thank you @pierreferry!

It's also possible to bypass this bug by specifying an order yourself, like so: SeedDump.dump(SomeThing.order(id: :asc)).