module Clear::SQL::Query::Select

Direct including types

Defined in:

clear/sql/query/select.cr

Instance Method Summary

Instance Method Detail

def clear_distinct #

Remove distinct


[View source]
def clear_select #

[View source]
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.


[View source]
def distinct(on : String | Nil = "") #

Add DISTINCT to the SELECT part of the query

  • If on is blank (empty string, default), will call a simple SELECT DISTINCT ...
  • If on is nil, will remove the distinct (see #clear_distinct)
  • If on is a non empty string, will call SELECT DISTINCT ON (on) ...

[View source]
def distinct_value : String | Nil #

[View source]
def select(c : Column) #

def select(name : Symbolic, var = nil) @columns << Column.new(name, var) self end


[View source]
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"

[View source]