Class: ODBCAdapter::ColumnMetadata
- Inherits:
-
Object
- Object
- ODBCAdapter::ColumnMetadata
- Defined in:
- lib/odbc_adapter/column_metadata.rb
Constant Summary collapse
- GENERICS =
{ primary_key: [ODBC::SQL_INTEGER, ODBC::SQL_SMALLINT], string: [ODBC::SQL_VARCHAR], text: [ODBC::SQL_LONGVARCHAR, ODBC::SQL_VARCHAR], integer: [ODBC::SQL_INTEGER, ODBC::SQL_SMALLINT], decimal: [ODBC::SQL_NUMERIC, ODBC::SQL_DECIMAL], float: [ODBC::SQL_DOUBLE, ODBC::SQL_REAL], datetime: [ODBC::SQL_TYPE_TIMESTAMP, ODBC::SQL_TIMESTAMP], timestamp: [ODBC::SQL_TYPE_TIMESTAMP, ODBC::SQL_TIMESTAMP], time: [ODBC::SQL_TYPE_TIME, ODBC::SQL_TIME, ODBC::SQL_TYPE_TIMESTAMP, ODBC::SQL_TIMESTAMP], date: [ODBC::SQL_TYPE_DATE, ODBC::SQL_DATE, ODBC::SQL_TYPE_TIMESTAMP, ODBC::SQL_TIMESTAMP], binary: [ODBC::SQL_LONGVARBINARY, ODBC::SQL_VARBINARY], boolean: [ODBC::SQL_BIT, ODBC::SQL_TINYINT, ODBC::SQL_SMALLINT, ODBC::SQL_INTEGER] }.freeze
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
-
#initialize(adapter) ⇒ ColumnMetadata
constructor
A new instance of ColumnMetadata.
- #native_database_types ⇒ Object
Constructor Details
#initialize(adapter) ⇒ ColumnMetadata
Returns a new instance of ColumnMetadata.
20 21 22 |
# File 'lib/odbc_adapter/column_metadata.rb', line 20 def initialize(adapter) @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
18 19 20 |
# File 'lib/odbc_adapter/column_metadata.rb', line 18 def adapter @adapter end |
Instance Method Details
#native_database_types ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/odbc_adapter/column_metadata.rb', line 24 def native_database_types grouped = reported_types.group_by { |row| row[1] } GENERICS.each_with_object({}) do |(abstract, candidates), mapped| candidates.detect do |candidate| next unless grouped[candidate] mapped[abstract] = native_type_mapping(abstract, grouped[candidate]) end end end |