trilogy-libraries / activerecord-trilogy-adapter

Active Record adapter for the Trilogy database client for Rails v6.0 - v7.0.
https://github.com/trilogy-libraries/trilogy
MIT License
172 stars 17 forks source link

Implement `with_multi_statements` to unblock concurrent fixture insertion #38

Closed paarthmadan closed 1 year ago

paarthmadan commented 1 year ago

Depends on https://github.com/github/trilogy/pull/52 Closes #37

This PR defines methods execute_batch and with_multi_statements to leverage multi statement insertion during the insert_fixture_set flow. It's mostly inspired by the implementation of Mysql2Adapter upstream, and much of this code can be de-duplicated when Trilogy makes its way upstream.

I've added 2 test cases for the cases when multi_statement is enabled/disabled to start.

Once we merge the Trilogy changes, I'll update this PR to use main/the new release.