Class: ActiveRecord::ConnectionAdapters::PostgreSQLColumn

Inherits:
JdbcColumn
  • Object
show all
Includes:
ArJdbc::PostgreSQL::Column
Defined in:
lib/arjdbc/postgresql/adapter.rb

Instance Attribute Summary

Attributes inherited from JdbcColumn

#limit, #precision

Instance Method Summary collapse

Methods included from ArJdbc::PostgreSQL::Column

#accessor, #default_value, #extract_bounds, #infinity, #number?, #text?, #type_cast

Methods inherited from JdbcColumn

column_types, #default_value, #init_column

Constructor Details

#initialize(name, default, oid_type = nil, sql_type = nil, null = true, fmod = nil, adapter = nil) ⇒ PostgreSQLColumn

Returns a new instance of PostgreSQLColumn.



1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
# File 'lib/arjdbc/postgresql/adapter.rb', line 1299

def initialize(name, default, oid_type = nil, sql_type = nil, null = true,
    fmod = nil, adapter = nil) # added due resolving #oid_type
  if oid_type.is_a?(Integer) # the "main" if branch (on AR 4.x)
    @oid = oid_type; @fmod = fmod; @adapter = adapter # see Column#oid_type
  elsif oid_type.respond_to?(:type_cast) # MRI compatibility
    @oid_type = oid_type; # @fmod = fmod; @adapter = adapter
  else # NOTE: AR <= 3.2 : (name, default, sql_type = nil, null = true)
    null, sql_type, oid_type = !! sql_type, oid_type, nil
  end
  if sql_type.to_s[-2, 2] == '[]' && ArJdbc::PostgreSQL::AR4_COMPAT
    @array = true if respond_to?(:array)
    super(name, default, sql_type[0..-3], null)
  else
    @array = false if respond_to?(:array)
    super(name, default, sql_type, null)
  end

  @default_function = default if has_default_function?(@default, default)
end