Class: Rooq::DSL::InsertQuery
- Inherits:
-
Object
- Object
- Rooq::DSL::InsertQuery
- Defined in:
- lib/rooq/dsl/insert_query.rb
Instance Attribute Summary collapse
-
#column_list ⇒ Object
readonly
Returns the value of attribute column_list.
-
#insert_values ⇒ Object
readonly
Returns the value of attribute insert_values.
-
#returning_fields ⇒ Object
readonly
Returns the value of attribute returning_fields.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
- #columns(*cols) ⇒ Object
-
#initialize(table) ⇒ InsertQuery
constructor
A new instance of InsertQuery.
- #returning(*fields) ⇒ Object
- #to_sql(dialect = Rooq::Dialect::PostgreSQL.new) ⇒ Object
- #values(*vals) ⇒ Object
Constructor Details
#initialize(table) ⇒ InsertQuery
Returns a new instance of InsertQuery.
8 9 10 11 12 13 |
# File 'lib/rooq/dsl/insert_query.rb', line 8 def initialize(table) @table = table @column_list = [] @insert_values = [] @returning_fields = [] end |
Instance Attribute Details
#column_list ⇒ Object (readonly)
Returns the value of attribute column_list.
6 7 8 |
# File 'lib/rooq/dsl/insert_query.rb', line 6 def column_list @column_list end |
#insert_values ⇒ Object (readonly)
Returns the value of attribute insert_values.
6 7 8 |
# File 'lib/rooq/dsl/insert_query.rb', line 6 def insert_values @insert_values end |
#returning_fields ⇒ Object (readonly)
Returns the value of attribute returning_fields.
6 7 8 |
# File 'lib/rooq/dsl/insert_query.rb', line 6 def returning_fields @returning_fields end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
6 7 8 |
# File 'lib/rooq/dsl/insert_query.rb', line 6 def table @table end |
Instance Method Details
#columns(*cols) ⇒ Object
15 16 17 |
# File 'lib/rooq/dsl/insert_query.rb', line 15 def columns(*cols) dup_with(column_list: cols.flatten) end |
#returning(*fields) ⇒ Object
23 24 25 |
# File 'lib/rooq/dsl/insert_query.rb', line 23 def returning(*fields) dup_with(returning_fields: fields.flatten) end |
#to_sql(dialect = Rooq::Dialect::PostgreSQL.new) ⇒ Object
27 28 29 |
# File 'lib/rooq/dsl/insert_query.rb', line 27 def to_sql(dialect = Rooq::Dialect::PostgreSQL.new) dialect.render_insert(self) end |
#values(*vals) ⇒ Object
19 20 21 |
# File 'lib/rooq/dsl/insert_query.rb', line 19 def values(*vals) dup_with(insert_values: @insert_values + [vals.flatten]) end |