Sha256: e35345cd7f93bc0371c27a2707d30bebd551f0148a06a7b5c543fa817d8468ad
Contents?: true
Size: 1001 Bytes
Versions: 2
Compression:
Stored size: 1001 Bytes
Contents
module ODBCAdapter # Caches SQLGetInfo output class DatabaseMetadata FIELDS = %i[ SQL_DBMS_NAME SQL_DBMS_VER SQL_IDENTIFIER_CASE SQL_QUOTED_IDENTIFIER_CASE SQL_IDENTIFIER_QUOTE_CHAR SQL_MAX_IDENTIFIER_LEN SQL_MAX_TABLE_NAME_LEN SQL_USER_NAME SQL_DATABASE_NAME ] attr_reader :values def initialize(connection) @values = Hash[FIELDS.map { |field| [field, connection.get_info(ODBC.const_get(field))] }] end def adapter_class ODBCAdapter.adapter_for(dbms_name) end def upcase_identifiers? @upcase_identifiers ||= (identifier_case == ODBC::SQL_IC_UPPER) end # A little bit of metaprogramming magic here to create accessors for each of # the fields reported on by the DBMS. FIELDS.each do |field| define_method(field.to_s.downcase.gsub('sql_', '')) do value_for(field) end end private def value_for(field) values[field] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
odbc_adapter-5.0.2 | lib/odbc_adapter/database_metadata.rb |
odbc_adapter-5.0.1 | lib/odbc_adapter/database_metadata.rb |