Skip to content

Commit 5489258

Browse files
committed
backwards compat for previous commit (tracking removed TRUE_VALUES in AR)
1 parent d504920 commit 5489258

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/arjdbc/jdbc/type_cast.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Jdbc
66
# @private Simply to quickly "hack-in" 4.2 compatibility.
77
module TypeCast
88

9-
TRUE_VALUES = Column::TRUE_VALUES
9+
TRUE_VALUES = Column::TRUE_VALUES if Column.const_defined?(:TRUE_VALUES)
1010
FALSE_VALUES = Column::FALSE_VALUES
1111

1212
#module Format
@@ -58,7 +58,16 @@ def value_to_boolean(value)
5858
else
5959
TRUE_VALUES.include?(value)
6060
end
61-
end
61+
end if const_defined?(:TRUE_VALUES) # removed on AR 5.0
62+
63+
# convert something to a boolean
64+
def value_to_boolean(value)
65+
if value.is_a?(String) && value.empty?
66+
nil
67+
else
68+
! FALSE_VALUES.include?(value)
69+
end
70+
end unless const_defined?(:TRUE_VALUES)
6271

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

0 commit comments

Comments
 (0)