class ActiveRecord::ConnectionAdapters::JdbcColumn

The base class for all of {JdbcAdapter}'s returned columns. Instances of {JdbcColumn} will get extended with “column-spec” modules (similar to how {JdbcAdapter} gets spec modules in) if the adapter spec module provided a `column_selector` (matcher) method for it's database specific type. @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_column_class

Attributes

limit[W]

@deprecated attribute writers will be removed in 1.4

precision[W]

@deprecated attribute writers will be removed in 1.4

Public Class Methods

column_types() click to toggle source

Returns the available column types @return [Hash] of (matcher, block) pairs

# File lib/arjdbc/jdbc/column.rb, line 57
def self.column_types
  types = {}
  for mod in ::ArJdbc.modules
    if mod.respond_to?(:column_selector)
      sel = mod.column_selector # [ matcher, block ]
      types[ sel[0] ] = sel[1]
    end
  end
  types
end
new(config, name, *args) click to toggle source
Calls superclass method
# File lib/arjdbc/jdbc/column.rb, line 16
def initialize(config, name, *args)
  if self.class == JdbcColumn
    # NOTE: extending classes do not want this if they do they shall call
    call_discovered_column_callbacks(config) if config
    default = args.shift
  else # for extending classes allow ignoring first argument :
    if ! config.nil? && ! config.is_a?(Hash)
      default = name; name = config # initialize(name, default, *args)
    else
      default = args.shift
    end
  end
  default = default_value(default)

  # super <= 4.1: (name, default, sql_type = nil, null = true)
  # super >= 4.2: (name, default, cast_type, sql_type = nil, null = true)
  super(name, default, *args)
  init_column(name, default, *args)
end
string_to_date(value) click to toggle source

@private provides compatibility between AR 3.x/4.0 API

# File lib/arjdbc/jdbc/column.rb, line 75
def string_to_date(value); value_to_date(value) end

Public Instance Methods

default_value(value) click to toggle source

Similar to `ActiveRecord`'s `extract_value_from_default(default)`. @return default value for a column (possibly extracted from driver value)

# File lib/arjdbc/jdbc/column.rb, line 41
def default_value(value); value; end
init_column(*args) click to toggle source

Additional column initialization for sub-classes.

# File lib/arjdbc/jdbc/column.rb, line 37
def init_column(*args); end

Protected Instance Methods

call_discovered_column_callbacks(config) click to toggle source

@private

# File lib/arjdbc/jdbc/column.rb, line 46
def call_discovered_column_callbacks(config)
  dialect = (config[:dialect] || config[:driver]).to_s
  for matcher, block in self.class.column_types
    block.call(config, self) if matcher === dialect
  end
end