class ActiveRecord::ConnectionAdapters::AdvantageAdapter
Public Instance Methods
exec_query(sql, name = "SQL", _binds = [])
click to toggle source
# File lib/active_record/connection_adapters/advantage_adapter.rb, line 243 def exec_query(sql, name = "SQL", _binds = []) cols, record = execute(sql, name) ActiveRecord::Result.new(cols, record) end
select_rows(sql, name = nil)
click to toggle source
Returns a query as an array of arrays
# File lib/active_record/connection_adapters/advantage_adapter.rb, line 260 def select_rows(sql, name = nil) exec_query(sql, name).rows end
Protected Instance Methods
options_include_default?(options)
click to toggle source
Required to prevent DEFAULT NULL being added to primary keys
# File lib/active_record/connection_adapters/advantage_adapter.rb, line 465 def options_include_default?(options) options.include?(:default) && !(options[:null] == false && options[:default].nil?) end
table_structure(table_name)
click to toggle source
Queries the structure of a table including the columns names, defaults, type, and nullability ActiveRecord
uses the type to parse scale and precision information out of the types. As a result, chars, varchars, binary, nchars, nvarchars must all be returned in the form type(width) numeric and decimal must be returned in the form type(width, scale) Nullability is returned as 0 (no nulls allowed) or 1 (nulls allowed) Alos, ActiveRecord
expects an autoincrement column to have default value of NULL
# File lib/active_record/connection_adapters/advantage_adapter.rb, line 453 def table_structure(table_name) # sql = "SELECT COLUMN_NAME, IIF(COLUMN_DEF = 'NULL', null, COLUMN_DEF) as COLUMN_DEF, IIF(TYPE_NAME = 'NUMERIC' and DECIMAL_DIGITS = 0, 'INTEGER', TYPE_NAME) as TYPE_NAME, NULLABLE from (EXECUTE PROCEDURE sp_GetColumns( NULL, NULL, '#{table_name}', NULL )) spgc where table_cat <> 'system';" sql = "SELECT COLUMN_NAME, IIF(COLUMN_DEF = 'NULL', null, COLUMN_DEF) as COLUMN_DEF, TYPE_NAME, NULLABLE from (EXECUTE PROCEDURE sp_GetColumns( NULL, NULL, '#{table_name}', NULL )) spgc where table_cat <> 'system';" structure = exec_query(sql, :skip_logging) raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure == false # Add in a "ROWID" column to the structure? structure.rows.unshift(['ROWID', nil, 'CHAR', 1]) if structure.rows.any? structure end
Private Instance Methods
initialize_type_map(m = type_map)
click to toggle source
Used in the lookup_cast_type procedure
Calls superclass method
# File lib/active_record/connection_adapters/advantage_adapter.rb, line 472 def initialize_type_map(m = type_map) super m.alias_type %r(memo)i, "char" m.alias_type %r(long binary)i, "binary" m.alias_type %r(integer)i, "int" m.alias_type %r(short)i, "int" m.alias_type %r(autoinc)i, "int" m.alias_type %r(logical)i, "boolean" end