Module: Babik::QuerySet::Update::Assignment
- Defined in:
- lib/babik/queryset/lib/update/assignment.rb
Overview
Field assignment module
Defined Under Namespace
Classes: Decrement, Divide, Function, Increment, Multiply, Operation
Class Method Summary collapse
-
._escape(str) ⇒ String
Escape a value for database.
-
.sql_field(model, field) ⇒ String
Return the field prepared for the UPDATE operation.
-
.sql_value(update_field_value) ⇒ String
Return the value prepared for the UPDATE operation.
Class Method Details
._escape(str) ⇒ String
Escape a value for database
40 41 42 |
# File 'lib/babik/queryset/lib/update/assignment.rb', line 40 def self._escape(str) Babik::Database.escape(str) end |
.sql_field(model, field) ⇒ String
Return the field prepared for the UPDATE operation. Used when rendering the SQL template
15 16 17 18 |
# File 'lib/babik/queryset/lib/update/assignment.rb', line 15 def self.sql_field(model, field) field = Babik::Table::Field.new(model, field) field.real_field end |
.sql_value(update_field_value) ⇒ String
Return the value prepared for the UPDATE operation. Used when rendering the SQL template
30 31 32 33 34 35 |
# File 'lib/babik/queryset/lib/update/assignment.rb', line 30 def self.sql_value(update_field_value) return update_field_value.sql_value if update_field_value.is_a?(Operation) || update_field_value.is_a?(Function) return _escape(update_field_value) if update_field_value.is_a?(String) return update_field_value.id if update_field_value.is_a?(ActiveRecord::Base) update_field_value end |