Module: Imparcial::Driver::AbstractExpression::Constraint
- Included in:
- Imparcial::Driver::AbstractExpression
- Defined in:
- lib/imparcial/driver/abstract/expression/constraint.rb
Instance Method Summary collapse
-
#add_auto_increment(options = {}) ⇒ Object
Description Make a bunch of fields auto increment.
-
#add_default_value(options = {}) ⇒ Object
Description Add default value for some fields.
-
#add_primary_key(options = {}) ⇒ Object
Description Make a bunch of fields primary key.
Instance Method Details
#add_auto_increment(options = {}) ⇒ Object
Description
Make a bunch of fields auto increment.
Usage
abstract_adapter.add_auto_increment :table_name => ‘person’, :fields => [‘id’,‘name’]
Options
-
:table_name
-
:fields
Returning
nothing
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/imparcial/driver/abstract/expression/constraint.rb', line 82 def add_auto_increment ( = {} ) , add_primary_key :table_name => [:table_name], :fields => [[:field]] sql = sql_for_adding_auto_increment( ) logger.warn sql if @column_logging query sql rescue adapter_specific_exception => ex raise ColumnConstraintError.new(ex.) end |
#add_default_value(options = {}) ⇒ Object
Description
Add default value for some fields.
Usage
abstract_adapter.add_default_value :table_name => ‘person’, :fields => => 1, :name => ‘jota’
Options
-
:table_name
-
:fields
Returning
nothing
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/imparcial/driver/abstract/expression/constraint.rb', line 129 def add_default_value ( = {} ) , sql = sql_for_adding_default_value( ) logger.warn sql if @column_logging query sql rescue adapter_specific_exception => ex raise ColumnConstraintError.new(ex.) end |
#add_primary_key(options = {}) ⇒ Object
Description
Make a bunch of fields primary key.
Usage
abstract_adapter.primary_key :table_name => ‘person’, :fields => [‘id’,‘name’]
Options
-
:table_name
-
:fields
Returning
nothing
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/imparcial/driver/abstract/expression/constraint.rb', line 36 def add_primary_key ( = {} ) , sql = sql_for_adding_primary_key( ) logger.warn sql if @column_logging query sql rescue adapter_specific_exception => ex raise ColumnConstraintError.new(ex.) end |