Sha256: 36322e3732f84b58e538229dfc17b7ad7c874937cf81c1d846a2767f30b64d77
Contents?: true
Size: 1008 Bytes
Versions: 1
Compression:
Stored size: 1008 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 ].freeze 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
odbc_adapter-5.0.3 | lib/odbc_adapter/database_metadata.rb |