module Clear::SQL::Query::Select
Direct including types
Defined in:
clear/sql/query/select.crInstance Method Summary
-
#clear_distinct
Remove distinct
- #clear_select
-
#default_wildcard_table=(table : String | Nil = nil)
In some case you want you query to return
table.*
instead of*
if no select parameters has been set. -
#distinct(on : String | Nil = "")
Add DISTINCT to the SELECT part of the query
- #distinct_value : String | Nil
-
#select(c : Column)
def select(name : Symbolic, var = nil) @columns << Column.new(name, var) self end
-
#select(*args)
Add field(s) to selection from tuple
Instance Method Detail
def default_wildcard_table=(table : String | Nil = nil)
#
In some case you want you query to return table.*
instead of *
if no select parameters has been set. This occurs in the case of joins
between models.
def distinct(on : String | Nil = "")
#
Add DISTINCT to the SELECT part of the query
- If
on
is blank (empty string, default), will call a simpleSELECT DISTINCT ...
- If
on
is nil, will remove the distinct (see#clear_distinct
) - If
on
is a non empty string, will callSELECT DISTINCT ON (on) ...
def select(name : Symbolic, var = nil) @columns << Column.new(name, var) self end
def select(*args)
#
Add field(s) to selection from tuple
select({user_id: "uid", updated_at: "updated_at"})
# => Output "SELECT user_id as uid, updated_at as updated_at"