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
class TableDefinition
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, 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
-
#initialize(name, temporary = false, options = nil, as = nil, comment: nil) ⇒ TableDefinition
constructor
def initialize(base, name=nil, temporary=nil, options=nil).
- #native ⇒ Object
-
#primary_keys(name = nil) ⇒ Object
:nodoc:.
- #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
Constructor Details
#initialize(name, temporary = false, options = nil, as = nil, comment: nil) ⇒ TableDefinition
def initialize(base, name=nil, temporary=nil, options=nil)
if(self.respond_to?(:indexes)) @ar3 = false else @ar3 = true end
@columns = [] @columns_hash = {} @indexes = {} @base = base @temporary = temporary @options = options @name = name @foreign_keys = {} end
586 587 588 589 590 591 592 593 594 595 596 597 598 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 586 def initialize(name, temporary = false, = nil, as = nil, comment: nil) @columns_hash = {} @indexes = [] @foreign_keys = [] @primary_keys = nil @temporary = temporary @options = @as = as @name = name @comment = comment ## #@base = base end |
Instance Method Details
#bigint(*args) ⇒ Object
649 650 651 652 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 649 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]
655 656 657 658 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 655 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
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 663 def column(name, type, ={}) # construct a column definition where @base is adaptor instance column = ColumnDefinition.new(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
634 635 636 637 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 634 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
628 629 630 631 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 628 def double(*args) ibm_parse_column_attributes_args('double',*args) return self end |
#graphic(*args) ⇒ Object
639 640 641 642 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 639 def graphic(*args) ibm_parse_column_attributes_args('graphic',*args) return self end |
#native ⇒ Object
605 606 607 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 605 def native @base.native_database_types end |
#primary_keys(name = nil) ⇒ Object
:nodoc:
600 601 602 603 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 600 def primary_keys(name = nil) # :nodoc: @primary_keys = PrimaryKeyDefinition.new(name) if name @primary_keys end |
#vargraphic(*args) ⇒ Object
644 645 646 647 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 644 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
622 623 624 625 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 622 def xml(*args ) ibm_parse_column_attributes_args('xml', *args) return self end |