module

Clear::SQL::SelectBuilder

Inherits Clear::SQL::Query::WithPagination < Clear::SQL::Query::BeforeQuery < Clear::SQL::Query::Change < Clear::SQL::Query::Connection < Clear::SQL::Query::Pluck < Clear::SQL::Query::Fetch < Clear::SQL::Query::Execute < Clear::SQL::Query::Lock < Clear::SQL::Query::Window < Clear::SQL::Query::CTE < Clear::SQL::Query::Aggregate < Clear::SQL::Query::OffsetLimit < Clear::SQL::Query::GroupBy < Clear::SQL::Query::OrderBy < Clear::SQL::Query::Having < Clear::SQL::Query::Where < Clear::SQL::Query::Join < Clear::SQL::Query::From < Clear::SQL::Query::Select

Constructors

new(distinct_value = nil, cte = {} of String => Clear::SQL::Query::CTE::Record, columns = [] of SQL::Column, forced_columns = [] of SQL::Column, froms = [] of SQL::From, joins = [] of SQL::Join, wheres = [] of Clear::Expression::Node, havings = [] of Clear::Expression::Node, windows = [] of ::Tuple(String, String), group_bys = [] of Symbolic, order_bys = [] of Clear::SQL::Query::OrderBy::Record, limit = nil, offset = nil, lock = nil, before_query_triggers = [] of (-> Nil))
Source

Instance methods

before_query

A hook to apply some operation just before the query is executed.

call = 0
req = Clear::SQL.select("1").before_query { call += 1 }
10.times { req.execute }
pp call # 10
Source
columns
default_wildcard_table
dup

Duplicate the current request. Select query are mutable objects, and many of the methods will change the state of the collection:

collection = User.query # SELECT * FROM users;
collection.select("id") # SELECT id FROM users;
collection.select("id") # SELECT id, id FROM users;

Therefore, you may want to use dup to duplicate the current state of the collection.

Source
havings
is_distinct?
Source
joins
limit
lock
offset
order_bys
to_delete

Construct and return a delete query from this select query

Note: It uses only the from and the where clause from the current select request.

Source
to_sql

Resolve the query

Source
to_update

Construct and return an update query from this select query

Note: It uses only the from and the where clause from the current select request.

Source
total_entries
total_entries=(total_entries : Int64 | Nil)
wheres

Return the list of where clause; each where clause are transformed into Clear::Expression::Node