Class: ODBCAdapter::DatabaseMetadata
- Inherits:
-
Object
- Object
- ODBCAdapter::DatabaseMetadata
- Defined in:
- lib/odbc_adapter/database_metadata.rb
Overview
Caches SQLGetInfo output
Constant Summary collapse
- 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
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #adapter_class ⇒ Object
-
#initialize(connection, has_encoding_bug = false) ⇒ DatabaseMetadata
constructor
has_encoding_bug refers to github.com/larskanis/ruby-odbc/issues/2 where ruby-odbc in UTF8 mode returns incorrectly encoded responses to getInfo.
- #upcase_identifiers? ⇒ Boolean
Constructor Details
#initialize(connection, has_encoding_bug = false) ⇒ DatabaseMetadata
has_encoding_bug refers to github.com/larskanis/ruby-odbc/issues/2 where ruby-odbc in UTF8 mode returns incorrectly encoded responses to getInfo
20 21 22 23 24 25 26 27 |
# File 'lib/odbc_adapter/database_metadata.rb', line 20 def initialize(connection, has_encoding_bug = false) @values = Hash[FIELDS.map do |field| info = connection.get_info(ODBC.const_get(field)) info = info.encode(Encoding.default_external, 'UTF-16LE') if info.is_a?(String) && has_encoding_bug [field, info] end] end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
16 17 18 |
# File 'lib/odbc_adapter/database_metadata.rb', line 16 def values @values end |
Instance Method Details
#adapter_class ⇒ Object
29 30 31 |
# File 'lib/odbc_adapter/database_metadata.rb', line 29 def adapter_class ODBCAdapter.adapter_for(dbms_name) end |
#upcase_identifiers? ⇒ Boolean
33 34 35 |
# File 'lib/odbc_adapter/database_metadata.rb', line 33 def upcase_identifiers? @upcase_identifiers ||= (identifier_case == ODBC::SQL_IC_UPPER) end |