Skip to content

Commit

Permalink
Fixing an issue with rails 5 enums.
Browse files Browse the repository at this point in the history
Don't use read_before_type_cast for enums as that will return a string for the enum key which is incorrect.

For example, this fixes failing tests when running:

   AR_VERSION=5.0 bundle exec rake test:mysql2
  • Loading branch information
zdennis committed Feb 26, 2016
1 parent 6dae70c commit 2a4e6f8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/activerecord-import/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,11 @@ def import_helper( *args )
# this next line breaks sqlite.so with a segmentation fault
# if model.new_record? || options[:on_duplicate_key_update]
column_names.map do |name|
if model.class.column_defaults[name.to_s].is_a? Integer
model.read_attribute(name.to_s)
name = name.to_s
if model.class.column_defaults[name].is_a?(Integer) || defined_enums.has_key?(name)
model.read_attribute(name)
else
model.read_attribute_before_type_cast(name.to_s)
model.read_attribute_before_type_cast(name)
end
end
# end
Expand Down

0 comments on commit 2a4e6f8

Please sign in to comment.