Class: ActiveRecord::ConnectionAdapters::ColumnMethods::TableDefinition
- Inherits:
-
TableDefinition
- Object
- TableDefinition
- ActiveRecord::ConnectionAdapters::ColumnMethods::TableDefinition
- Defined in:
- lib/active_record/connection_adapters/ibm_db_adapter.rb
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
733 734 735 736 737 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 733 def bigint(*args) puts_log '32' ibm_parse_column_attributes_args('bigint', *args) 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]
740 741 742 743 744 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 740 def char(*args) puts_log '33' ibm_parse_column_attributes_args('char', *args) 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
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 749 def column(name, type, index: nil, **) puts_log '34 column' name = name.to_s type = type.to_sym if type if @columns_hash[name] unless @columns_hash[name].primary_key? raise ArgumentError, "you can't define an already defined column '#{name}'." end raise ArgumentError, "you can't redefine the primary key column '#{name}'. To define a custom primary key, pass { id: false } to create_table." 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 if type.to_s == 'xml' 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}" sql << ' NOT NULL' if !null.nil? && (null == false) sql end else column.null = [:null] column.default = [:default] 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] if @base.native_database_types[type.to_sym].has_key? :limit column.limit = @base.native_database_types[type.to_sym][:limit] end end @columns << column unless @columns.nil? or @columns.include? column @columns_hash[name] = column self end |
#decfloat(*args) ⇒ Object
Method to support the new syntax of rails 2.0 migrations (short-hand definitions) for columns of type decfloat
715 716 717 718 719 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 715 def decfloat(*args) puts_log '29' ibm_parse_column_attributes_args('decfloat', *args) self end |
#double(*args) ⇒ Object
Method to support the new syntax of rails 2.0 migrations (short-hand definitions) for columns of type double
708 709 710 711 712 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 708 def double(*args) puts_log '28' ibm_parse_column_attributes_args('double', *args) self end |
#graphic(*args) ⇒ Object
721 722 723 724 725 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 721 def graphic(*args) puts_log '30' ibm_parse_column_attributes_args('graphic', *args) self end |
#native ⇒ Object
684 685 686 687 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 684 def native puts_log '25' @base.native_database_types end |
#vargraphic(*args) ⇒ Object
727 728 729 730 731 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 727 def vargraphic(*args) puts_log '31' ibm_parse_column_attributes_args('vargraphic', *args) self end |
#xml(*args) ⇒ Object
Method to support the new syntax of rails 2.0 migrations for columns of type xml
701 702 703 704 705 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 701 def xml(*args) puts_log '27' ibm_parse_column_attributes_args('xml', *args) self end |