Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Use bulk INSERT to insert fixtures #29504
This patch improves the performance of inserting fixtures from O(n) to O(1).
Disabled on sqlite which doesn't support multiple inserts.
While 1k fixtures may sound unrealistic, at Shopify scale we have hundreds of tables, each having up to 100 fixtures. In our app this patch dramatically improved the performance of test helper. This patch would be especially helpful for those apps who use
FYI, SQLite does support multi-row inserts since version 3.7.11 (released in 2012, see changelog), but in some CIs older versions are being used by default, so you need to upgrade SQLite first (like this: travis-ci/apt-package-safelist#368 (comment))
Maybe it worth adding a version check in implementation for SQLite?
TIL. Thanks for the tip, I'll look into it!…
On Jun 25, 2017 2:03 PM, "Andrey Novikov" ***@***.***> wrote: FYI, SQLite does support multi-row inserts since version 3.7.11 (released in 2012, see changelog <http://sqlite.org/releaselog/3_7_11.html>), but in some CIs older versions are being used by default, so you need to upgrade SQLite first (like this: travis-ci/apt-package-safelist#368 (comment) <travis-ci/apt-package-safelist#368 (comment)> ) Maybe it worth adding a version check in implementation for SQLite? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#29504 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAf3qxSnWtmDxfHJHs8jL7Dtso6tUB6zks5sHqDYgaJpZM4N_Byw> .
@Envek I just realized that there was another reason why I couldn't use SQLite for bulk insert.
As a placeholder for default values (those columns that were not specified in a fixture), we use
I found that SQLite doesn't support
Since rails#29504, mysql2 adapter lost ability to insert zero value on primary key due to enforce `NO_AUTO_VALUE_ON_ZERO` disabled. That is for using `DEFAULT` on auto increment column, but we can use `NULL` instead in that case.