Class: ActiveRecord::ConnectionAdapters::TableDefinition
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::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, 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(base, name = nil, temporary = nil, options = nil) ⇒ TableDefinition
constructor
A new instance of TableDefinition.
- #native ⇒ Object
- #vargraphic(*args) ⇒ Object
-
#xml(*args) ⇒ Object
Method to support the new syntax of rails 2.0 migrations for columns of type xml.
Constructor Details
#initialize(base, name = nil, temporary = nil, options = nil) ⇒ TableDefinition
Returns a new instance of TableDefinition.
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 439 def initialize(base, name=nil, temporary=nil, =nil) if(self.respond_to?(:indexes)) @ar3 = false else @ar3 = true end @columns = [] @columns_hash = {} @indexes = {} @base = base @temporary = temporary @options = @name = name @foreign_keys = {} end |
Instance Method Details
#bigint(*args) ⇒ Object
499 500 501 502 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 499 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]
505 506 507 508 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 505 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
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 513 def column(name, type, ={}) # construct a column definition where @base is adaptor instance if(@ar3) column = ColumnDefinition.new(@base, name, type) else column = ColumnDefinition.new(name, type) end # 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
484 485 486 487 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 484 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
478 479 480 481 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 478 def double(*args) ibm_parse_column_attributes_args('double',*args) return self end |
#graphic(*args) ⇒ Object
489 490 491 492 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 489 def graphic(*args) ibm_parse_column_attributes_args('graphic',*args) return self end |
#native ⇒ Object
455 456 457 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 455 def native @base.native_database_types end |
#vargraphic(*args) ⇒ Object
494 495 496 497 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 494 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
472 473 474 475 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 472 def xml(*args ) ibm_parse_column_attributes_args('xml', *args) return self end |