Class: ActiveRecord::ConnectionAdapters::JdbcColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/jdbc_adapter/jdbc_sqlite3.rb,
lib/active_record/connection_adapters/jdbc_adapter.rb

Constant Summary collapse

COLUMN_TYPES =
::JdbcSpec.constants.map{|c|
::JdbcSpec.const_get c }.select{ |c|
c.respond_to? :column_selector }.map{|c|
c.column_selector }.inject({}) { |h,val|
h[val[0]] = val[1]; h }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, name, default, *args) ⇒ JdbcColumn

Returns a new instance of JdbcColumn.



276
277
278
279
280
281
282
283
284
285
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 276

def initialize(config, name, default, *args)
  dialect = config[:dialect] || config[:driver]
  for reg, func in COLUMN_TYPES
    if reg === dialect.to_s
      func.call(config,self)
    end
  end
  super(name,default_value(default),*args)
  init_column(name, default, *args)
end

Instance Attribute Details

#limit=(value) ⇒ Object (writeonly)

Sets the attribute limit

Parameters:

  • value

    the value to set the attribute limit to.



268
269
270
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 268

def limit=(value)
  @limit = value
end

#precision=(value) ⇒ Object (writeonly)

Sets the attribute precision

Parameters:

  • value

    the value to set the attribute precision to.



268
269
270
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 268

def precision=(value)
  @precision = value
end

Class Method Details

.binary_to_string(value) ⇒ Object



374
375
376
377
378
379
380
381
# File 'lib/jdbc_adapter/jdbc_sqlite3.rb', line 374

def self.binary_to_string(value)
  value.gsub(/%00|%25/n) do |b|
    case b
      when "%00" then "\0"
      when "%25" then "%"
    end
  end
end

.string_to_binary(value) ⇒ Object



365
366
367
368
369
370
371
372
# File 'lib/jdbc_adapter/jdbc_sqlite3.rb', line 365

def self.string_to_binary(value)
  value.gsub(/\0|%/n) do |b|
    case b
      when "\0" then "%00"
      when "\%"  then "%25"
    end
  end
end

Instance Method Details

#default_value(val) ⇒ Object



290
291
292
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 290

def default_value(val)
  val
end

#init_column(*args) ⇒ Object



287
288
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 287

def init_column(*args)
end