Skip to content

Commit bf9b733

Browse files
authored
Merge pull request rails#55015 from skipkayhil/hm-sqlite-booleans-2
Use TRUE and FALSE for more SQLite queries
2 parents 308b705 + 576db3b commit bf9b733

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

activerecord/lib/active_record/connection_adapters/sqlite3/quoting.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,10 @@ def quoted_binary(value)
8080
"x'#{value.hex}'"
8181
end
8282

83-
def quoted_true
84-
"1"
85-
end
86-
8783
def unquoted_true
8884
1
8985
end
9086

91-
def quoted_false
92-
"0"
93-
end
94-
9587
def unquoted_false
9688
0
9789
end

activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ def extract_value_from_default(default)
564564
# Binary columns
565565
when /x'(.*)'/
566566
[ $1 ].pack("H*")
567+
when "TRUE", "FALSE"
568+
default
567569
else
568570
# Anything else is blank or some function
569571
# and we can't know the value of that, so return nil.

activerecord/test/cases/adapters/sqlite3/bind_parameter_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_where_with_float_for_string_column_using_bind_parameters
2222
end
2323

2424
def test_where_with_boolean_for_string_column_using_bind_parameters
25-
assert_quoted_as "0", false
25+
assert_quoted_as "FALSE", false
2626
end
2727

2828
def test_where_with_decimal_for_string_column_using_bind_parameters

0 commit comments

Comments
 (0)