| Module | Sequel::JDBC::SQLServer::DatabaseMethods::MetadataDatasetMethods |
| In: |
lib/sequel/adapters/jdbc/sqlserver.rb
|
Work around a bug in SQL Server JDBC Driver 3.0, where the metadata for the getColumns result set specifies an incorrect type for the IS_AUTOINCREMENT column. The column is a string, but the type is specified as a short. This causes getObject() to throw a com.microsoft.sqlserver.jdbc.SQLServerException: "The conversion from char to SMALLINT is unsupported." Using getString() rather than getObject() for this column avoids the problem. Reference: social.msdn.microsoft.com/Forums/en/sqldataaccess/thread/20df12f3-d1bf-4526-9daa-239a83a8e435
# File lib/sequel/adapters/jdbc/sqlserver.rb, line 21
21: def process_result_set_convert(cols, result, rn)
22: while result.next
23: row = {}
24: cols.each do |n, i, p|
25: v = (n == :is_autoincrement ? result.getString(i) : result.getObject(i))
26: row[n] = if v
27: if p
28: p.call(v)
29: elsif p.nil?
30: cols[i-1][2] = p = convert_type_proc(v)
31: if p
32: p.call(v)
33: else
34: v
35: end
36: else
37: v
38: end
39: else
40: v
41: end
42: end
43: row.delete(rn) if rn
44: yield row
45: end
46: end
# File lib/sequel/adapters/jdbc/sqlserver.rb, line 48
48: def process_result_set_no_convert(cols, result, rn)
49: while result.next
50: row = {}
51: cols.each do |n, i|
52: row[n] = (n == :is_autoincrement ? result.getString(i) : result.getObject(i))
53: end
54: row.delete(rn) if rn
55: yield row
56: end
57: end