Class: Rooq::DSL::UpdateQuery
- Inherits:
-
Object
- Object
- Rooq::DSL::UpdateQuery
- Defined in:
- lib/rooq/dsl/update_query.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#returning_fields ⇒ Object
readonly
Returns the value of attribute returning_fields.
-
#set_values ⇒ Object
readonly
Returns the value of attribute set_values.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(table) ⇒ UpdateQuery
constructor
A new instance of UpdateQuery.
- #returning(*fields) ⇒ Object
- #set(field, value) ⇒ Object
- #to_sql(dialect = Rooq::Dialect::PostgreSQL.new) ⇒ Object
- #where(condition) ⇒ Object
Constructor Details
#initialize(table) ⇒ UpdateQuery
Returns a new instance of UpdateQuery.
8 9 10 11 12 13 |
# File 'lib/rooq/dsl/update_query.rb', line 8 def initialize(table) @table = table @set_values = {} @conditions = nil @returning_fields = [] end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
6 7 8 |
# File 'lib/rooq/dsl/update_query.rb', line 6 def conditions @conditions end |
#returning_fields ⇒ Object (readonly)
Returns the value of attribute returning_fields.
6 7 8 |
# File 'lib/rooq/dsl/update_query.rb', line 6 def returning_fields @returning_fields end |
#set_values ⇒ Object (readonly)
Returns the value of attribute set_values.
6 7 8 |
# File 'lib/rooq/dsl/update_query.rb', line 6 def set_values @set_values end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
6 7 8 |
# File 'lib/rooq/dsl/update_query.rb', line 6 def table @table end |
Instance Method Details
#returning(*fields) ⇒ Object
24 25 26 |
# File 'lib/rooq/dsl/update_query.rb', line 24 def returning(*fields) dup_with(returning_fields: fields.flatten) end |
#set(field, value) ⇒ Object
15 16 17 18 |
# File 'lib/rooq/dsl/update_query.rb', line 15 def set(field, value) new_set_values = @set_values.merge(field => value) dup_with(set_values: new_set_values) end |
#to_sql(dialect = Rooq::Dialect::PostgreSQL.new) ⇒ Object
28 29 30 |
# File 'lib/rooq/dsl/update_query.rb', line 28 def to_sql(dialect = Rooq::Dialect::PostgreSQL.new) dialect.render_update(self) end |
#where(condition) ⇒ Object
20 21 22 |
# File 'lib/rooq/dsl/update_query.rb', line 20 def where(condition) dup_with(conditions: condition) end |