module ArJdbc::H2::Column
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/h2/adapter.rb, line 66 def default_value(value) # H2 auto-generated key default value return nil if value =~ /^\(NEXT VALUE FOR/i # JDBC returns column default strings with actual single quotes around the value. return $1 if value =~ /^'(.*)'$/ value end
extract_limit(sql_type)
click to toggle source
Calls superclass method
# File lib/arjdbc/h2/adapter.rb, line 24 def extract_limit(sql_type) limit = super case @sql_type = sql_type.downcase # NOTE: JDBC driver f*cks sql_type up with limits (just like HSQLDB) : when /^tinyint/i then @sql_type = 'tinyint'; limit = 1 when /^smallint|int2/i then @sql_type = 'smallint'; limit = 2 when /^bigint|int8/i then @sql_type = 'bigint'; limit = 8 when /^int|int4/i then @sql_type = 'int'; limit = 4 when /^double/i then @sql_type = 'double'; limit = 8 when /^real/i then @sql_type = 'real'; limit = 4 when /^date/i then @sql_type = 'date'; limit = nil when /^timestamp/i then @sql_type = 'timestamp'; limit = nil when /^time/i then @sql_type = 'time'; limit = nil when /^boolean/i then @sql_type = 'boolean'; limit = nil when /^binary|bytea/i; then @sql_type = 'binary'; limit = 2 * 1024 * 1024 when /blob|image|oid/i then @sql_type = 'blob'; limit = nil when /clob|text/i then @sql_type = 'clob'; limit = nil # NOTE: use lower-case due SchemaDumper not handling it's decimal/integer # optimization case-insensitively due : column.type == :integer && # [/^numeric/, /^decimal/].any? { |e| e.match(column.sql_type) } when /^decimal\(65535,32767\)/i @sql_type = 'decimal'; nil end limit end
simplified_type(field_type)
click to toggle source
Calls superclass method
# File lib/arjdbc/h2/adapter.rb, line 50 def simplified_type(field_type) case field_type when /^bit|bool/i then :boolean when /^signed|year/i then :integer when /^real|double/i then :float when /^varchar/i then :string when /^longvarchar/i then :text when /^binary|raw|bytea/i then :binary when /varbinary/i then :binary # longvarbinary, varbinary when /^blob|image|oid/i then :binary else super end end