module

Lustra::SQL::SelectBuilder

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

Constructors

new(distinct_value = nil, cte = {} of String => Lustra::SQL::SelectBuilder | String, columns = [] of SQL::Column, froms = [] of SQL::From, joins = [] of SQL::Join, wheres = [] of Lustra::Expression::Node, havings = [] of Lustra::Expression::Node, windows = [] of ::Tuple(String, String), group_bys = [] of Symbolic, order_bys = [] of Lustra::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 = Lustra::SQL.select("1").before_query { call += 1 }
10.times { req.execute }
pp call # 10
Source
clear_before_query_triggers

Remove callbacks registered to run before the query executes.

Source
columns
default_wildcard_table
dup

Duplicate the query

Source
havings
is_distinct?
Source
joins
limit
lock
offset
order_bys
to_delete

Construct a delete query from this select query. It uses only the from and the where clause fo the current select request. Can be useful in some case, but use at your own risk !

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

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