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

Includes:
MSSQL::DatabaseMethods
Defined in:
lib/sequel/adapters/jdbc/sqlserver.rb

Overview

Database instance methods for SQLServer databases accessed via JDBC.

Constant Summary

Constants included from MSSQL::DatabaseMethods

MSSQL::DatabaseMethods::PRIMARY_KEY_INDEX_RE

Constants included from MSSQL::DatabaseMethods

MSSQL::DatabaseMethods::AUTO_INCREMENT, MSSQL::DatabaseMethods::DECIMAL_TYPE_RE, MSSQL::DatabaseMethods::SERVER_VERSION_RE, MSSQL::DatabaseMethods::SERVER_VERSION_SQL, MSSQL::DatabaseMethods::SQL_BEGIN, MSSQL::DatabaseMethods::SQL_COMMIT, MSSQL::DatabaseMethods::SQL_ROLLBACK, MSSQL::DatabaseMethods::SQL_ROLLBACK_TO_SAVEPOINT, MSSQL::DatabaseMethods::SQL_SAVEPOINT

Instance Attribute Summary

Attributes included from MSSQL::DatabaseMethods

#mssql_unicode_strings

Instance Method Summary collapse

Methods included from MSSQL::DatabaseMethods

#database_type, #server_version, #supports_savepoints?, #supports_transaction_isolation_levels?, #tables, #views

Instance Method Details

#metadata_datasetObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sequel/adapters/jdbc/sqlserver.rb', line 12

def 
  ds = super
  # 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: http://social.msdn.microsoft.com/Forums/en/sqldataaccess/thread/20df12f3-d1bf-4526-9daa-239a83a8e435
  def ds.result_set_object_getter
    lambda do |result, n, i|
      if n == :is_autoincrement
        @convert_types ? convert_type(result.getString(i)) : result.getString(i)
      else
        @convert_types ? convert_type(result.getObject(i)) : result.getObject(i)
      end
    end
  end
  ds
end