Skip to content

Commit

Permalink
backwards compat for previous commit (tracking removed TRUE_VALUES in…
Browse files Browse the repository at this point in the history
… AR)
  • Loading branch information
kares committed Mar 8, 2016
1 parent d504920 commit 5489258
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/arjdbc/jdbc/type_cast.rb
Expand Up @@ -6,7 +6,7 @@ module Jdbc
# @private Simply to quickly "hack-in" 4.2 compatibility.
module TypeCast

TRUE_VALUES = Column::TRUE_VALUES
TRUE_VALUES = Column::TRUE_VALUES if Column.const_defined?(:TRUE_VALUES)
FALSE_VALUES = Column::FALSE_VALUES

#module Format
Expand Down Expand Up @@ -58,7 +58,16 @@ def value_to_boolean(value)
else
TRUE_VALUES.include?(value)
end
end
end if const_defined?(:TRUE_VALUES) # removed on AR 5.0

# convert something to a boolean
def value_to_boolean(value)
if value.is_a?(String) && value.empty?
nil
else
! FALSE_VALUES.include?(value)
end
end unless const_defined?(:TRUE_VALUES)

# Used to convert values to integer.
# handle the case when an integer column is used to store boolean values
Expand Down

0 comments on commit 5489258

Please sign in to comment.