-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).