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.
411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 411 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 end |
Instance Method Details
#bigint(*args) ⇒ Object
470 471 472 473 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 470 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]
476 477 478 479 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 476 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
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 484 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
455 456 457 458 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 455 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
449 450 451 452 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 449 def double(*args) ibm_parse_column_attributes_args('double',*args) return self end |
#graphic(*args) ⇒ Object
460 461 462 463 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 460 def graphic(*args) ibm_parse_column_attributes_args('graphic',*args) return self end |
#native ⇒ Object
426 427 428 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 426 def native @base.native_database_types end |
#vargraphic(*args) ⇒ Object
465 466 467 468 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 465 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
443 444 445 446 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 443 def xml(*args ) ibm_parse_column_attributes_args('xml', *args) return self end |