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
-
#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.
-
#xml(*args) ⇒ Object
Method to support the new syntax of rails 2.0 migrations for columns of type xml.
Instance Method Details
#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]
329 330 331 332 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 329 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
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 337 def column(name, type, ={}) # construct a column definition where @base is adaptor instance column = ColumnDefinition.new(@base, 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.include? column @columns << column end 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
323 324 325 326 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 323 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
317 318 319 320 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 317 def double(*args) ibm_parse_column_attributes_args('double',*args) return self end |
#xml(*args) ⇒ Object
Method to support the new syntax of rails 2.0 migrations for columns of type xml
311 312 313 314 |
# File 'lib/active_record/connection_adapters/ibm_db_adapter.rb', line 311 def xml(*args ) ibm_parse_column_attributes_args('xml', *args) return self end |