Skip to content

Commit daa65e4

Browse files
rsovkares
authored andcommitted
[DB2] Update quote to match param signature of AR51 and up (#975)
1 parent 51369d4 commit daa65e4

File tree

1 file changed

+2
-52
lines changed

1 file changed

+2
-52
lines changed

lib/arjdbc/db2/adapter.rb

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -342,60 +342,10 @@ def pk_and_sequence_for(table)
342342

343343
# Properly quotes the various data types.
344344
# @param value contains the data
345-
# @param column (optional) contains info on the field
346345
# @override
347-
def quote(value, column = nil)
348-
return value.quoted_id if value.respond_to?(:quoted_id)
346+
def quote(value)
349347
return value if sql_literal?(value)
350-
351-
if column
352-
if column.respond_to?(:primary) && column.primary && column.klass != String
353-
return value.to_i.to_s
354-
end
355-
if value && (column.type.to_sym == :decimal || column.type.to_sym == :integer)
356-
return value.to_s
357-
end
358-
end
359-
360-
column_type = column && column.type.to_sym
361-
362-
case value
363-
when nil then 'NULL'
364-
when Numeric # IBM_DB doesn't accept quotes on numeric types
365-
# if the column type is text or string, return the quote value
366-
if column_type == :text || column_type == :string
367-
"'#{value}'"
368-
else
369-
value.to_s
370-
end
371-
when String, ActiveSupport::Multibyte::Chars
372-
if column_type == :binary && column.sql_type !~ /for bit data/i
373-
if update_lob_value?(value, column)
374-
value.nil? ? 'NULL' : BLOB_VALUE_MARKER # '@@@IBMBINARY@@@'"
375-
else
376-
"BLOB('#{quote_string(value)}')"
377-
end
378-
elsif column && column.sql_type =~ /clob/ # :text
379-
if update_lob_value?(value, column)
380-
value.nil? ? 'NULL' : CLOB_VALUE_MARKER # "'@@@IBMTEXT@@@'"
381-
else
382-
"'#{quote_string(value)}'"
383-
end
384-
elsif column_type == :xml
385-
value.nil? ? 'NULL' : "'#{quote_string(value)}'" # "'<ibm>@@@IBMXML@@@</ibm>'"
386-
else
387-
"'#{quote_string(value)}'"
388-
end
389-
when Symbol then "'#{quote_string(value.to_s)}'"
390-
when Time
391-
# AS400 doesn't support date in time column
392-
if column_type == :time
393-
quote_time(value)
394-
else
395-
super
396-
end
397-
else super
398-
end
348+
super
399349
end
400350

401351
# @override

0 commit comments

Comments
 (0)