Class: ActiveRecord::ConnectionAdapters::TableDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/ibm_db_adapter.rb

Instance Method Summary collapse

Instance Method Details

#bigint(*args) ⇒ Object



387
388
389
390
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 387

def bigint(*args)
  ibm_parse_column_attributes_args('bigint',*args)
  return self
end

#char(*args) ⇒ Object Also known as: character

Method to support the new syntax of rails 2.0 migrations (short-hand definitions) for columns of type char [character]



393
394
395
396
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 393

def char(*args)
  ibm_parse_column_attributes_args('char',*args)
  return self
end

#column(name, type, options = {}) ⇒ Object

Overrides the abstract adapter in order to handle the DEFAULT option for the native XML datatype



401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 401

def column(name, type, options ={})
  # construct a column definition where @base is adaptor instance
  column = ColumnDefinition.new(@base, name, type)

  # DB2 does not accept DEFAULT NULL option for XML
  # for table create, but does accept nullable option
  unless type.to_s == 'xml'
    column.null    = options[:null]
    column.default = options[:default]
  else
    column.null    = options[:null]
    # Override column object's (instance of ColumnDefinition structure)
    # to_s which is expected to return the create_table SQL fragment
    # and bypass DEFAULT NULL option while still appending NOT NULL
    def column.to_s
      sql = "#{base.quote_column_name(name)} #{type}"
      unless self.null == nil
        sql << " NOT NULL" if (self.null == false)
      end
      return sql
    end
  end

  column.scale     = options[:scale]      if options[:scale]
  column.precision = options[:precision]  if options[:precision]
  # append column's limit option and yield native limits
  if options[:limit]
    column.limit   = options[:limit]
  elsif @base.native_database_types[type.to_sym]
    column.limit   = @base.native_database_types[type.to_sym][:limit] if @base.native_database_types[type.to_sym].has_key? :limit
  end

  unless @columns.include? column
    @columns << column 
  end
  return self
end

#decfloat(*args) ⇒ Object

Method to support the new syntax of rails 2.0 migrations (short-hand definitions) for columns of type decfloat



372
373
374
375
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 372

def decfloat(*args)
  ibm_parse_column_attributes_args('decfloat',*args)
  return self
end

#double(*args) ⇒ Object

Method to support the new syntax of rails 2.0 migrations (short-hand definitions) for columns of type double



366
367
368
369
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 366

def double(*args)
  ibm_parse_column_attributes_args('double',*args)
  return self
end

#graphic(*args) ⇒ Object



377
378
379
380
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 377

def graphic(*args)
  ibm_parse_column_attributes_args('graphic',*args)
  return self
end

#vargraphic(*args) ⇒ Object



382
383
384
385
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 382

def vargraphic(*args)
  ibm_parse_column_attributes_args('vargraphic',*args)
  return self
end

#xml(*args) ⇒ Object

Method to support the new syntax of rails 2.0 migrations for columns of type xml



360
361
362
363
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 360

def xml(*args )
  ibm_parse_column_attributes_args('xml', *args)
  return self
end