Module: SQB::Columns
- Included in:
- Select
- Defined in:
- lib/sqb/columns.rb
Instance Method Summary collapse
-
#column(column, options = {}) ⇒ Query
Add a column to the query.
-
#column!(*args) ⇒ Object
Replace all existing columns with the given column.
Instance Method Details
#column(column, options = {}) ⇒ Query
Add a column to the query
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sqb/columns.rb', line 10 def column(column, = {}) @columns ||= [] with_table_and_column(column) do |table, column| @columns << [].tap do |query| if [:function] query << "#{escape_function([:function])}(" end query << escape_and_join(table, column) if [:function] query << ")" end if [:as] query << "AS" query << escape([:as]) end end.join(' ') end self end |
#column!(*args) ⇒ Object
Replace all existing columns with the given column
31 32 33 34 |
# File 'lib/sqb/columns.rb', line 31 def column!(*args) @columns = [] column(*args) end |