Packages
cake
0.3.0
4.1.0
4.0.0
3.0.0
2.2.2
2.2.1
2.2.0
2.1.3
2.1.2
2.1.1
2.1.0
2.0.2
2.0.1
2.0.0
1.1.2
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-rc.0
retired
0.15.0
retired
0.14.0
retired
0.13.0
retired
0.12.0
retired
0.11.0
retired
0.10.1
retired
0.10.0
retired
0.9.2
retired
0.9.1
retired
0.9.0
retired
0.8.0
retired
0.7.0
retired
0.6.0
retired
0.5.0
retired
0.4.0
retired
0.3.0
retired
0.2.0
retired
0.1.0
retired
0.0.1
retired
🎂 An SQL query builder for Gleam for SQL dialects 🐘PostgreSQL, 🪶SQLite, 🦭MariaDB, and 🐬MySQL
Retired package: Deprecated - a stable release is available, please use >= 1.0.0
Current section
Files
Jump to
Current section
Files
src/cake@query@update.erl
-module(cake@query@update).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([to_query/1, bool/1, float/1, int/1, string/1, new/2, col_to_param/2, col_to_expression/2, col_to_sub_query/2, cols_to_expression/2, cols_to_sub_query/2, returning/2, no_returning/1, comment/2, no_comment/1]).
-spec to_query(cake@internal@write_query:update(PCW)) -> cake@internal@write_query:write_query(PCW).
to_query(Updt) ->
_pipe = Updt,
{update_query, _pipe}.
-spec bool(boolean()) -> cake@param:param().
bool(Vl) ->
_pipe = Vl,
cake@param:bool(_pipe).
-spec float(float()) -> cake@param:param().
float(Vl) ->
_pipe = Vl,
cake@param:float(_pipe).
-spec int(integer()) -> cake@param:param().
int(Vl) ->
_pipe = Vl,
cake@param:int(_pipe).
-spec string(binary()) -> cake@param:param().
string(Vl) ->
_pipe = Vl,
cake@param:string(_pipe).
-spec new(binary(), list(cake@internal@write_query:update_set())) -> cake@internal@write_query:update(any()).
new(Tbl, Sts) ->
{update,
{update_table, Tbl},
no_update_modifier,
{update_sets, Sts},
no_update_from,
no_where,
no_returning,
no_comment}.
-spec col_to_param(binary(), cake@param:param()) -> cake@internal@write_query:update_set().
col_to_param(Col, Prm) ->
{update_param_set, Col, Prm}.
-spec col_to_expression(binary(), binary()) -> cake@internal@write_query:update_set().
col_to_expression(Col, Exp) ->
{update_expression_set, [Col], Exp}.
-spec col_to_sub_query(binary(), cake@internal@query:'query'()) -> cake@internal@write_query:update_set().
col_to_sub_query(Col, Qry) ->
{update_sub_query_set, [Col], Qry}.
-spec cols_to_expression(list(binary()), binary()) -> cake@internal@write_query:update_set().
cols_to_expression(Cols, Exp) ->
{update_expression_set, Cols, Exp}.
-spec cols_to_sub_query(list(binary()), cake@internal@query:'query'()) -> cake@internal@write_query:update_set().
cols_to_sub_query(Cols, Qry) ->
{update_sub_query_set, Cols, Qry}.
-spec returning(cake@internal@write_query:update(PDE), list(binary())) -> cake@internal@write_query:update(PDE).
returning(Qry, Rtrn) ->
case Rtrn of
[] ->
erlang:setelement(7, Qry, no_returning);
_ ->
erlang:setelement(7, Qry, {returning, Rtrn})
end.
-spec no_returning(cake@internal@write_query:update(PDI)) -> cake@internal@write_query:update(PDI).
no_returning(Qry) ->
erlang:setelement(7, Qry, no_returning).
-spec comment(cake@internal@write_query:update(PDL), binary()) -> cake@internal@write_query:update(PDL).
comment(Qry, Cmmnt) ->
Cmmnt@1 = begin
_pipe = Cmmnt,
gleam@string:trim(_pipe)
end,
case Cmmnt@1 of
<<""/utf8>> ->
erlang:setelement(8, Qry, no_comment);
_ ->
erlang:setelement(8, Qry, {comment, Cmmnt@1})
end.
-spec no_comment(cake@internal@write_query:update(PDO)) -> cake@internal@write_query:update(PDO).
no_comment(Qry) ->
erlang:setelement(8, Qry, no_comment).