Class: ActiveRecord::ConnectionAdapters::OracleColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/connection_adapters/oracle_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, default, sql_type = nil, null = true) ⇒ OracleColumn

Returns a new instance of OracleColumn.



9
10
11
12
# File 'lib/connection_adapters/oracle_adapter.rb', line 9

def initialize(name, default, sql_type = nil, null = true)
  if !(default.nil? || default.blank?) then @default_specified = true end
  super(name, default, sql_type, null)
end

Instance Attribute Details

#default_spceifiedObject

Returns the value of attribute default_spceified.



7
8
9
# File 'lib/connection_adapters/oracle_adapter.rb', line 7

def default_spceified
  @default_spceified
end

#primary_keyObject

Returns the value of attribute primary_key.



7
8
9
# File 'lib/connection_adapters/oracle_adapter.rb', line 7

def primary_key
  @primary_key
end

Instance Method Details

#default_specified?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/connection_adapters/oracle_adapter.rb', line 15

def default_specified?
  @default_specified
end

#generated?Boolean

The only means that Oracle currently provides for auto-generating a column is to define a sequence and a trigger on insert that inserts sequence.nextval

As a result of this, there is no reliable way to determine whether a particular column is generated by the DB.

DrySQL currently makes the assumption that a column is auto-generated if the column is of type integer and is the primary key for the table

Ideally a future release of Oracle will support declaring a default value of sequence.nextval for a column, which will eliminate this problem.

Returns:

  • (Boolean)


30
31
32
# File 'lib/connection_adapters/oracle_adapter.rb', line 30

def generated?
  @type == :integer && @primary_key == true
end