File tree Expand file tree Collapse file tree 4 files changed +17
-20
lines changed
activerecord/lib/active_record/connection_adapters Expand file tree Collapse file tree 4 files changed +17
-20
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,10 @@ def quoted_time(value) # :nodoc:
141141 quoted_date ( value ) . sub ( /\A 2000-01-01 / , "" )
142142 end
143143
144+ def quoted_binary ( value ) # :nodoc:
145+ "'#{ quote_string ( value . to_s ) } '"
146+ end
147+
144148 private
145149
146150 def type_casted_binds ( binds )
@@ -153,14 +157,15 @@ def types_which_need_no_typecasting
153157
154158 def _quote ( value )
155159 case value
156- when String , ActiveSupport ::Multibyte ::Chars , Type :: Binary :: Data
160+ when String , ActiveSupport ::Multibyte ::Chars
157161 "'#{ quote_string ( value . to_s ) } '"
158162 when true then quoted_true
159163 when false then quoted_false
160164 when nil then "NULL"
161165 # BigDecimals need to be put in a non-normalized form and quoted.
162166 when BigDecimal then value . to_s ( "F" )
163167 when Numeric , ActiveSupport ::Duration then value . to_s
168+ when Type ::Binary ::Data then quoted_binary ( value )
164169 when Type ::Time ::Value then "'#{ quoted_time ( value ) } '"
165170 when Date , Time then "'#{ quoted_date ( value ) } '"
166171 when Symbol then "'#{ quote_string ( value . to_s ) } '"
Original file line number Diff line number Diff line change @@ -36,15 +36,9 @@ def quoted_date(value)
3636 end
3737 end
3838
39- private
40-
41- def _quote ( value )
42- if value . is_a? ( Type ::Binary ::Data )
43- "x'#{ value . hex } '"
44- else
45- super
46- end
47- end
39+ def quoted_binary ( value )
40+ "x'#{ value . hex } '"
41+ end
4842 end
4943 end
5044 end
Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ def quoted_date(value) #:nodoc:
5555 end
5656 end
5757
58+ def quoted_binary ( value ) # :nodoc:
59+ "'#{ escape_bytea ( value . to_s ) } '"
60+ end
61+
5862 def quote_default_expression ( value , column ) # :nodoc:
5963 if value . is_a? ( Proc )
6064 value . call
@@ -76,8 +80,6 @@ def lookup_cast_type_from_column(column) # :nodoc:
7680
7781 def _quote ( value )
7882 case value
79- when Type ::Binary ::Data
80- "'#{ escape_bytea ( value . to_s ) } '"
8183 when OID ::Xml ::Data
8284 "xml '#{ quote_string ( value . to_s ) } '"
8385 when OID ::Bit ::Data
Original file line number Diff line number Diff line change @@ -18,15 +18,11 @@ def quoted_time(value)
1818 quoted_date ( value )
1919 end
2020
21- private
21+ def quoted_binary ( value )
22+ "x'#{ value . hex } '"
23+ end
2224
23- def _quote ( value )
24- if value . is_a? ( Type ::Binary ::Data )
25- "x'#{ value . hex } '"
26- else
27- super
28- end
29- end
25+ private
3026
3127 def _type_cast ( value )
3228 case value
You can’t perform that action at this time.
0 commit comments