Skip to content

Restore rails < 5 mysql support - #78

Merged
mberlanda merged 2 commits into
masterfrom
restore-rails-3-4-mysql-support
Feb 28, 2021
Merged

mberlanda merged 2 commits into
masterfrom
restore-rails-3-4-mysql-support

Conversation

@mberlanda

Copy link
Copy Markdown
Collaborator

In #77 I was able to reproduce in unit tests the issue describe in #41:

  1) Error:
BulkInsertWorkerTest#test_explicit_nil_should_override_defaults:
NoMethodError: undefined method `fields' for nil:NilClass
    /home/travis/.rvm/gems/ruby-2.3.8/gems/activerecord-4.2.11.3/lib/active_record/connection_adapters/mysql2_adapter.rb:222:in `exec_query'
    /home/travis/build/jamis/bulk_insert/lib/bulk_insert/worker.rb:96:in `execute_query'
    /home/travis/build/jamis/bulk_insert/lib/bulk_insert/worker.rb:86:in `save!'
    /home/travis/build/jamis/bulk_insert/test/bulk_insert/worker_test.rb:67:in `block in <class:BulkInsertWorkerTest>'

It looks like v1.6.0...v1.7.0 broke the compatibility for mysql adapter on rails < 5.

This pr fixes the issue and restore the support for mysql rails < 5.
It also enforce a strict test suite for mysql adapter (prepared in #74 #75 #76 ) to ensure that similar regressions won't happen in the future.

@mberlanda
mberlanda force-pushed the restore-rails-3-4-mysql-support branch 2 times, most recently from 8639fa5 to 38d7e55 Compare February 23, 2021 22:38
@mberlanda
mberlanda force-pushed the restore-rails-3-4-mysql-support branch from 38d7e55 to 68204a3 Compare February 23, 2021 22:52

@mberlanda mberlanda left a comment •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pr is almost ready. only this rails 3 test is not passing

================================================================================
Error: test_with_option_to_return_primary_keys,_worker_should_have_result_sets(BulkInsertTest):
  NoMethodError: undefined method `<=' for #<Regexp:0x000000000320b428>
  Did you mean?  <=>
================================================================================

@jamis, @bradrf, @rperryng, @tom0932, @antonyr, @prettybot, @rfbezerra, @DmitryRibalka, @philister, @waynerobinson, @darthwiz, @maxKimoby

I would love to hear your feedback about this pr resolving #41

Comment thread test/bulk_insert_test.rb Outdated
# in rails 3 test chaining the conditions with && raises the following exception
# NoMethodError: undefined method `<=' for #<Regexp:0x0000000003a23ed0>
if worker.adapter_name =~ /^mysql/i
assert_raise(ArgumentError, /BulkInsert does not support @return_primary_keys for mysql and rails < 5/) do

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mberlanda
mberlanda force-pushed the restore-rails-3-4-mysql-support branch from 6a704b7 to f2d3cdc Compare February 23, 2021 23:21
@mberlanda
mberlanda merged commit 4a69aff into master Feb 28, 2021
@mberlanda
mberlanda deleted the restore-rails-3-4-mysql-support branch February 28, 2021 20:41
pomier pushed a commit to pomier/bulk_insert that referenced this pull request Mar 29, 2021
* Restore rails < 5 mysql support

* Fix rails 3 tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant