Class: ActiveRecord::ConnectionAdapters::ColumnMethods::TableDefinition
- Inherits:
-
TableDefinition
- Object
- TableDefinition
- ActiveRecord::ConnectionAdapters::ColumnMethods::TableDefinition
- Defined in:
- lib/active_record/connection_adapters/ibm_db_adapter.rb
Overview
end of class Table
Instance Method Summary collapse
- #bigint(*args) ⇒ Object
-
#char(*args) ⇒ Object
(also: #character)
Method to support the new syntax of rails 2.0 migrations (short-hand definitions) for columns of type char [character].
-
#column(name, type, index: nil, **options) ⇒ Object
Overrides the abstract adapter in order to handle the DEFAULT option for the native XML datatype.
-
#decfloat(*args) ⇒ Object
Method to support the new syntax of rails 2.0 migrations (short-hand definitions) for columns of type decfloat.
-
#double(*args) ⇒ Object
Method to support the new syntax of rails 2.0 migrations (short-hand definitions) for columns of type double.
- #graphic(*args) ⇒ Object
- #native ⇒ Object
- #vargraphic(*args) ⇒ Object
-
#xml(*args) ⇒ Object
Method to support the new syntax of rails 2.0 migrations for columns of type xml.
Methods included from ActiveRecord::ConnectionAdapters::ColumnMethods
Instance Method Details
#bigint(*args) ⇒ Object
597 598 599 600 601 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 597 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]
604 605 606 607 608 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 604 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
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 659 660 661 662 663 664 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 613 def column(name, type, index: nil, **) 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, **) # DB2 does not accept DEFAULT NULL option for XML # for table create, but does accept nullable option unless type.to_s == 'xml' column.null = [:null] column.default = [:default] else column.null = [: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 = [:scale] if [:scale] column.precision = [:precision] if [:precision] # append column's limit option and yield native limits if [:limit] column.limit = [: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
579 580 581 582 583 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 579 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
572 573 574 575 576 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 572 def double(*args) puts_log "28" ibm_parse_column_attributes_args('double',*args) return self end |
#graphic(*args) ⇒ Object
585 586 587 588 589 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 585 def graphic(*args) puts_log "30" ibm_parse_column_attributes_args('graphic',*args) return self end |
#native ⇒ Object
546 547 548 549 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 546 def native puts_log "25" @base.native_database_types end |
#vargraphic(*args) ⇒ Object
591 592 593 594 595 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 591 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
565 566 567 568 569 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 565 def xml(*args ) puts_log "27" ibm_parse_column_attributes_args('xml', *args) return self end |