Current section
Files
Jump to
Current section
Files
src/cquill@query@ast.erl
-module(cquill@query@ast).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/cquill/query/ast.gleam").
-export([new/1, new_qualified/2, order_by_asc/1, order_by_desc/1, new_insert/1, new_insert_qualified/2, new_update/1, new_update_qualified/2, new_delete/1, new_delete_qualified/2]).
-export_type(['query'/1, source/0, select/0, select_expression/0, expr/0, aggregate_func/0, binary_op/0, where/0, condition/0, value/0, order_by/0, direction/0, nulls_order/0, join/0, join_type/0, query_operation/0, insert_query/1, on_conflict/0, update_query/1, set_clause/0, delete_query/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-type 'query'(QIS) :: {'query',
source(),
select(),
list(where()),
list(order_by()),
gleam@option:option(integer()),
gleam@option:option(integer()),
list(join()),
boolean(),
list(binary()),
list(where())} |
{gleam_phantom, QIS}.
-type source() :: {table_source, binary(), gleam@option:option(binary())} |
{subquery_source, 'query'(nil)}.
-type select() :: select_all |
{select_fields, list(binary())} |
{select_expr, list(select_expression())}.
-type select_expression() :: {select_expression,
expr(),
gleam@option:option(binary())}.
-type expr() :: {column_expr, binary()} |
{qualified_column_expr, binary(), binary()} |
{literal_expr, value()} |
{aggregate_expr, aggregate_func(), binary()} |
{function_expr, binary(), list(expr())} |
{binary_expr, expr(), binary_op(), expr()}.
-type aggregate_func() :: count | sum | avg | min | max | count_distinct.
-type binary_op() :: add | subtract | multiply | divide | concat.
-type where() :: {where, condition()}.
-type condition() :: {eq, binary(), value()} |
{not_eq, binary(), value()} |
{gt, binary(), value()} |
{gte, binary(), value()} |
{lt, binary(), value()} |
{lte, binary(), value()} |
{in, binary(), list(value())} |
{not_in, binary(), list(value())} |
{like, binary(), binary()} |
{not_like, binary(), binary()} |
{i_like, binary(), binary()} |
{not_i_like, binary(), binary()} |
{is_null, binary()} |
{is_not_null, binary()} |
{between, binary(), value(), value()} |
{'and', list(condition())} |
{'or', list(condition())} |
{'not', condition()} |
{raw, binary(), list(value())}.
-type value() :: {int_value, integer()} |
{float_value, float()} |
{string_value, binary()} |
{bool_value, boolean()} |
null_value |
{param_value, integer()} |
{list_value, list(value())}.
-type order_by() :: {order_by, binary(), direction(), nulls_order()}.
-type direction() :: asc | desc.
-type nulls_order() :: nulls_default | nulls_first | nulls_last.
-type join() :: {join,
join_type(),
binary(),
gleam@option:option(binary()),
condition()}.
-type join_type() :: inner_join |
left_join |
right_join |
full_join |
cross_join.
-type query_operation() :: select_op | insert_op | update_op | delete_op.
-type insert_query(QIT) :: {insert_query,
binary(),
gleam@option:option(binary()),
list(binary()),
list(list(value())),
gleam@option:option(on_conflict()),
list(binary())} |
{gleam_phantom, QIT}.
-type on_conflict() :: do_nothing |
{do_update, list(binary()), list(binary())} |
{do_nothing_on_constraint, binary()} |
{do_update_on_constraint, binary(), list(binary())}.
-type update_query(QIU) :: {update_query,
binary(),
gleam@option:option(binary()),
list(set_clause()),
list(where()),
list(binary())} |
{gleam_phantom, QIU}.
-type set_clause() :: {set_clause, binary(), value()}.
-type delete_query(QIV) :: {delete_query,
binary(),
gleam@option:option(binary()),
list(where()),
list(binary())} |
{gleam_phantom, QIV}.
-file("src/cquill/query/ast.gleam", 251).
?DOC(" Create a new empty Query AST for a table source\n").
-spec new(binary()) -> 'query'(nil).
new(Table) ->
{'query',
{table_source, Table, none},
select_all,
[],
[],
none,
none,
[],
false,
[],
[]}.
-file("src/cquill/query/ast.gleam", 267).
?DOC(" Create a new empty Query AST with schema qualification\n").
-spec new_qualified(binary(), binary()) -> 'query'(nil).
new_qualified(Schema_name, Table) ->
{'query',
{table_source, Table, {some, Schema_name}},
select_all,
[],
[],
none,
none,
[],
false,
[],
[]}.
-file("src/cquill/query/ast.gleam", 283).
?DOC(" Create a default OrderBy with ascending order\n").
-spec order_by_asc(binary()) -> order_by().
order_by_asc(Field) ->
{order_by, Field, asc, nulls_default}.
-file("src/cquill/query/ast.gleam", 288).
?DOC(" Create a default OrderBy with descending order\n").
-spec order_by_desc(binary()) -> order_by().
order_by_desc(Field) ->
{order_by, Field, desc, nulls_default}.
-file("src/cquill/query/ast.gleam", 328).
?DOC(" Create a new empty InsertQuery AST\n").
-spec new_insert(binary()) -> insert_query(nil).
new_insert(Table) ->
{insert_query, Table, none, [], [], none, []}.
-file("src/cquill/query/ast.gleam", 340).
?DOC(" Create a new InsertQuery AST with schema qualification\n").
-spec new_insert_qualified(binary(), binary()) -> insert_query(nil).
new_insert_qualified(Schema_name, Table) ->
{insert_query, Table, {some, Schema_name}, [], [], none, []}.
-file("src/cquill/query/ast.gleam", 381).
?DOC(" Create a new empty UpdateQuery AST\n").
-spec new_update(binary()) -> update_query(nil).
new_update(Table) ->
{update_query, Table, none, [], [], []}.
-file("src/cquill/query/ast.gleam", 392).
?DOC(" Create a new UpdateQuery AST with schema qualification\n").
-spec new_update_qualified(binary(), binary()) -> update_query(nil).
new_update_qualified(Schema_name, Table) ->
{update_query, Table, {some, Schema_name}, [], [], []}.
-file("src/cquill/query/ast.gleam", 425).
?DOC(" Create a new empty DeleteQuery AST\n").
-spec new_delete(binary()) -> delete_query(nil).
new_delete(Table) ->
{delete_query, Table, none, [], []}.
-file("src/cquill/query/ast.gleam", 430).
?DOC(" Create a new DeleteQuery AST with schema qualification\n").
-spec new_delete_qualified(binary(), binary()) -> delete_query(nil).
new_delete_qualified(Schema_name, Table) ->
{delete_query, Table, {some, Schema_name}, [], []}.