@@ -75,6 +75,22 @@ def self.emulate_booleans; @@emulate_booleans; end
7575 # @see #emulate_booleans?
7676 def self . emulate_booleans = ( emulate ) ; @@emulate_booleans = emulate ; end
7777
78+
79+ # Updating records with LOB values (binary/text columns) in a separate
80+ # statement can be disabled using :
81+ #
82+ # ArJdbc::Firebird.update_lob_values = false
83+ def self . update_lob_values? ; @@update_lob_values ; end
84+ # @see #update_lob_values?
85+ def self . update_lob_values = ( update ) ; @@update_lob_values = update ; end
86+
87+ # @see #update_lob_values?
88+ def update_lob_values? ; Firebird . update_lob_values? ; end
89+
90+ # @see #quote
91+ # @private
92+ BLOB_VALUE_MARKER = "''"
93+
7894 ADAPTER_NAME = 'Firebird' . freeze
7995
8096 def adapter_name
@@ -222,8 +238,15 @@ def quote(value, column = nil)
222238 return value if sql_literal? ( value )
223239
224240 type = column && column . type
241+
225242 # BLOBs are updated separately by an after_save trigger.
226- return "NULL" if type == :binary || type == :text
243+ if type == :binary || type == :text
244+ if update_lob_values?
245+ return value . nil? ? "NULL" : BLOB_VALUE_MARKER
246+ else
247+ return "'#{ quote_string ( value ) } '"
248+ end
249+ end
227250
228251 case value
229252 when String , ActiveSupport ::Multibyte ::Chars
@@ -279,6 +302,11 @@ def quoted_false
279302 quote ( 0 )
280303 end
281304
305+ # @override
306+ def quote_table_name_for_assignment ( table , attr )
307+ quote_column_name ( attr )
308+ end if ::ActiveRecord ::VERSION ::MAJOR >= 4
309+
282310 # @override
283311 def quote_column_name ( column_name )
284312 column_name = column_name . to_s
0 commit comments