Class: PGB::Query
- Inherits:
-
Expression
- Object
- Expression
- PGB::Query
- Extended by:
- Mutable
- Includes:
- Executable
- Defined in:
- lib/pgb/query.rb
Instance Method Summary collapse
-
#initialize(table = nil, *expressions) ⇒ Query
constructor
TODO Support everything www.postgresql.org/docs/current/sql-select.html TODO Table can be other things, e.g.
-
#to_sql ⇒ Object
TODO Can not select star if no table.
Methods included from Mutable
Methods included from Executable
Methods included from SQLDisplayable
Constructor Details
#initialize(table = nil, *expressions) ⇒ Query
TODO Support everything www.postgresql.org/docs/current/sql-select.html TODO Table can be other things, e.g. query
11 12 13 14 |
# File 'lib/pgb/query.rb', line 11 def initialize(table = nil, *expressions) self.table = table self.expressions = expressions end |
Instance Method Details
#to_sql ⇒ Object
TODO Can not select star if no table
17 18 19 20 21 |
# File 'lib/pgb/query.rb', line 17 def to_sql "SELECT #{expressions.any? ? expressions.map(&:to_sql).join(', ') : '*'}".then do table ? "#{_1} FROM #{table}" : _1 end end |