Class: ActiveRecord::ConnectionAdapters::ColumnMethods::TableDefinition

Inherits:
TableDefinition
  • Object
show all
Includes:
ActiveRecord::ConnectionAdapters::ColumnMethods
Defined in:
lib/active_record/connection_adapters/ibm_db_adapter.rb

Overview

end of class Table

Instance Method Summary collapse

Methods included from ActiveRecord::ConnectionAdapters::ColumnMethods

#primary_key

Instance Method Details

#bigint(*args) ⇒ Object



591
592
593
594
595
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 591

def bigint(*args)
        puts_log "32"
  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]



598
599
600
601
602
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 598

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

#column(name, type, index: nil, **options) ⇒ Object

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



607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 607

def column(name, type, index: nil, **options)
        puts_log "34 column"
        name = name.to_s
        type = type.to_sym if type
          
        if @columns_hash[name]
          if @columns_hash[name].primary_key?
            raise ArgumentError, "you can't redefine the primary key column '#{name}'. To define a custom primary key, pass { id: false } to create_table."
          else
            raise ArgumentError, "you can't define an already defined column '#{name}'."
          end
        end

        # construct a column definition where @base is adaptor instance
  column = new_column_definition(name, type, **options)
	
  # 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.nil? or @columns.include? column
    @columns << column
  end

  @columns_hash[name] = column

  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



573
574
575
576
577
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 573

def decfloat(*args)
        puts_log "29"
  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



566
567
568
569
570
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 566

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

#graphic(*args) ⇒ Object



579
580
581
582
583
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 579

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

#nativeObject



540
541
542
543
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 540

def native
        puts_log "25"
  @base.native_database_types
end

#vargraphic(*args) ⇒ Object



585
586
587
588
589
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 585

def vargraphic(*args)
        puts_log "31"
  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



559
560
561
562
563
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 559

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