Packages
cake
0.1.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@fragment.erl
-module(cake@query@fragment).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([literal/1, prepared/2]).
-spec literal(binary()) -> cake@internal@query:fragment().
literal(Str) ->
_pipe = Str,
{fragment_literal, _pipe}.
-spec prepared(binary(), list(cake@param:param())) -> cake@internal@query:fragment().
prepared(Str, Prms) ->
Plchldr_count = begin
_pipe = Str,
_pipe@1 = cake@internal@query:fragment_prepared_split_string(_pipe),
cake@internal@query:fragment_count_placeholders(_pipe@1)
end,
Param_count = begin
_pipe@2 = Prms,
erlang:length(_pipe@2)
end,
case {Plchldr_count,
Param_count,
begin
_pipe@3 = Plchldr_count,
gleam@int:compare(_pipe@3, Param_count)
end} of
{0, 0, eq} ->
_pipe@4 = Str,
{fragment_literal, _pipe@4};
{_, _, eq} ->
_pipe@5 = Str,
{fragment_prepared, _pipe@5, Prms};
{0, _, _} ->
gleam@io:println_error(
<<<<<<<<"Fragment had 0 "/utf8, (<<"$"/utf8>>)/binary>>/binary,
"-placeholders, but there were "/utf8>>/binary,
(gleam@int:to_string(Param_count))/binary>>/binary,
" params given!"/utf8>>
),
_pipe@6 = Str,
{fragment_literal, _pipe@6};
{_, 0, _} ->
gleam@io:println_error(
<<<<<<<<"Fragment had "/utf8,
(gleam@int:to_string(Plchldr_count))/binary>>/binary,
" "/utf8>>/binary,
(<<"$"/utf8>>)/binary>>/binary,
"-placeholders, but there were 0 params given!"/utf8>>
),
_pipe@7 = Str,
{fragment_literal, _pipe@7};
{_, _, _} ->
gleam@io:println_error(
<<<<<<<<<<<<"Fragment had "/utf8,
(gleam@int:to_string(Plchldr_count))/binary>>/binary,
" "/utf8>>/binary,
(<<"$"/utf8>>)/binary>>/binary,
"-placeholders, but there were "/utf8>>/binary,
(gleam@int:to_string(Param_count))/binary>>/binary,
" params given!"/utf8>>
),
_pipe@8 = Str,
{fragment_prepared, _pipe@8, Prms}
end.