Module: Sequel::JDBC::SQLServer::DatabaseMethods::MetadataDatasetMethods

Defined in:
lib/sequel/adapters/jdbc/sqlserver.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#basic_type_convertor(map, meta, type, i) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/sequel/adapters/jdbc/sqlserver.rb', line 40

def basic_type_convertor(map, meta, type, i)
  if output_identifier(meta.getColumnLabel(i)) == :is_autoincrement
    map[Java::JavaSQL::Types::VARCHAR]
  else
    super
  end
end

#type_convertor(map, meta, type, i) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/sequel/adapters/jdbc/sqlserver.rb', line 32

def type_convertor(map, meta, type, i)
  if output_identifier(meta.getColumnLabel(i)) == :is_autoincrement
    map[Java::JavaSQL::Types::VARCHAR]
  else
    super
  end
end