Clear::SQL::Query::Select
Instance methods
clear_force_select
Sourceclear_select
Sourcedistinct(on : String | Nil = "")
Add DISTINCT to the SELECT part of the query
- If
onis blank (empty string, default), will call a simpleSELECT DISTINCT ... - If
onis nil, will remove the distinct (seeclear_distinct) - If
onis a non empty string, will callSELECT DISTINCT ON (on) ...
distinct_value
Sourceforce_select(c : Column)
Sourceforce_select(*__args)
Act as select method, but is not cleared by clear_select
This is useful for enriching a query which absolutely need some key colums, for example this is used in relations caching under the hood.
query.force_select("id")
query.select("a, b").to_sql # => Output "SELECT a, b, id"
query.clear_select.to_sql # => Output "SELECT *, id"
force_select
Sourceselect(*__args)
Add columns in the SELECT query.
By default, a new SELECT query will select all using wildcard *.
After a call to select is made, the query will select the given fields instead.
select(user_id: "uid", updated_at: "updated_at")
# => Output "SELECT user_id as uid, updated_at as updated_at"
select
Sourceset_default_table_wildcard(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.
ameba:disable Naming/AccessorMethodName