module ArJdbc::Derby::Column
@note Part of this module is implemented in “native” Java. @see ActiveRecord::ConnectionAdapters::JdbcColumn
Private Instance Methods
default_value(value)
click to toggle source
Post process default value from JDBC into a Rails-friendly format (columns{-internal})
# File lib/arjdbc/derby/adapter.rb, line 88 def default_value(value) # JDBC returns column default strings with actual single quotes around the value. return $1 if value =~ /^'(.*)'$/ return nil if value == "GENERATED_BY_DEFAULT" value end
extract_limit(sql_type)
click to toggle source
Calls superclass method
# File lib/arjdbc/derby/adapter.rb, line 48 def extract_limit(sql_type) case @sql_type = sql_type.downcase when /^smallint/i then @sql_type = 'smallint'; limit = 2 when /^bigint/i then @sql_type = 'bigint'; limit = 8 when /^double/i then @sql_type = 'double'; limit = 8 # DOUBLE PRECISION when /^real/i then @sql_type = 'real'; limit = 4 when /^integer/i then @sql_type = 'integer'; limit = 4 when /^datetime/i then @sql_type = 'datetime'; limit = nil when /^timestamp/i then @sql_type = 'timestamp'; limit = nil when /^time/i then @sql_type = 'time'; limit = nil when /^date/i then @sql_type = 'date'; limit = nil when /^xml/i then @sql_type = 'xml'; limit = nil else limit = super # handle maximum length for a VARCHAR string : limit = 32672 if ! limit && @sql_type.index('varchar') == 0 end limit end
simplified_type(field_type)
click to toggle source
Calls superclass method
# File lib/arjdbc/derby/adapter.rb, line 68 def simplified_type(field_type) case field_type when /^smallint/i then Derby.emulate_booleans? ? :boolean : :integer when /^bigint|int/i then :integer when /^real|double/i then :float when /^dec/i then # DEC is a DECIMAL alias extract_scale(field_type) == 0 ? :integer : :decimal when /^timestamp/i then :datetime when /^xml/i then :xml when 'long varchar' then :text when /for bit data/i then :binary # :name=>"long varchar for bit data", :limit=>32700 # :name=>"varchar() for bit data", :limit=>32672 # :name=>"char() for bit data", :limit=>254} else super end end