Packages
cake
2.2.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
Current section
Files
Jump to
Current section
Files
src/cake@where.erl
-module(cake@where).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/cake/where.gleam").
-export([col/1, float/1, int/1, string/1, null/0, date/1, true/0, false/0, sub_query/1, fragment_value/1, 'not'/1, 'and'/1, 'or'/1, 'xor'/1, none/0, is_bool/2, is_not_bool/2, is_false/1, is_true/1, is_null/1, is_not_null/1, eq/2, lt/2, lte/2, gt/2, gte/2, eq_any_query/2, lt_any_query/2, lte_any_query/2, gt_any_query/2, gte_any_query/2, eq_all_query/2, lt_all_query/2, lte_all_query/2, gt_all_query/2, gte_all_query/2, in_query/2, in/2, exists_in_query/1, between/3, like/2, ilike/2, similar_to/3, fragment/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.
?MODULEDOC(
" Used to build `WHERE` clauses for SQL queries.\n"
"\n"
" Where clauses are used to filter rows in a table.\n"
"\n"
" Also used to build `HAVING` clauses for SQL queries, because they work the\n"
" same way as `WHERE` clauses, but are used to filter rows after `GROUP BY`\n"
" has been applied.\n"
"\n"
" ## Compatibility\n"
"\n"
" - 🪶SQLite does not support `ANY`, `ALL` and `SIMILAR TO`.\n"
"\n"
).
-file("src/cake/where.gleam", 49).
?DOC(" Creates a `WhereValue` from a column name `String`.\n").
-spec col(binary()) -> cake@internal@read_query:where_value().
col(Name) ->
_pipe = Name,
{where_column_value, _pipe}.
-file("src/cake/where.gleam", 55).
?DOC(" Creates a `WhereValue` from a `Float`.\n").
-spec float(float()) -> cake@internal@read_query:where_value().
float(Vl) ->
_pipe = Vl,
_pipe@1 = {float_param, _pipe},
{where_param_value, _pipe@1}.
-file("src/cake/where.gleam", 61).
?DOC(" Creates a `WhereValue` from an `Int`.\n").
-spec int(integer()) -> cake@internal@read_query:where_value().
int(Vl) ->
_pipe = Vl,
_pipe@1 = {int_param, _pipe},
{where_param_value, _pipe@1}.
-file("src/cake/where.gleam", 67).
?DOC(" Creates a `WhereValue` from a `String`.\n").
-spec string(binary()) -> cake@internal@read_query:where_value().
string(Vl) ->
_pipe = Vl,
_pipe@1 = {string_param, _pipe},
{where_param_value, _pipe@1}.
-file("src/cake/where.gleam", 73).
?DOC(" Creates a `NULL` `WhereValue`.\n").
-spec null() -> cake@internal@read_query:where_value().
null() ->
_pipe = null_param,
{where_param_value, _pipe}.
-file("src/cake/where.gleam", 79).
?DOC(" Creates a `WhereValue` from a `calendar.Date`.\n").
-spec date(gleam@time@calendar:date()) -> cake@internal@read_query:where_value().
date(Vl) ->
_pipe = Vl,
_pipe@1 = {date_param, _pipe},
{where_param_value, _pipe@1}.
-file("src/cake/where.gleam", 87).
?DOC(
" Creates a `TRUE` `WhereValue`.\n"
"\n"
" Notice: You probably want to use `where.is_true()` instead.\n"
).
-spec true() -> cake@internal@read_query:where_value().
true() ->
_pipe = true,
_pipe@1 = {bool_param, _pipe},
{where_param_value, _pipe@1}.
-file("src/cake/where.gleam", 95).
?DOC(
" Creates a `FALSE` `WhereValue`.\n"
"\n"
" Notice: You probably want to use `where.is_false()` instead.\n"
).
-spec false() -> cake@internal@read_query:where_value().
false() ->
_pipe = false,
_pipe@1 = {bool_param, _pipe},
{where_param_value, _pipe@1}.
-file("src/cake/where.gleam", 103).
?DOC(
" Creates a `WhereValue` off a `ReadQuery`.\n"
"\n"
" NOTICE: Usually the sub-query must return a single column.\n"
).
-spec sub_query(cake@internal@read_query:read_query()) -> cake@internal@read_query:where_value().
sub_query(Qry) ->
_pipe = Qry,
{where_sub_query_value, _pipe}.
-file("src/cake/where.gleam", 109).
?DOC(" Creates a `WhereValue` from a `Fragment`.\n").
-spec fragment_value(cake@internal@read_query:fragment()) -> cake@internal@read_query:where_value().
fragment_value(Frgmt) ->
_pipe = Frgmt,
{where_fragment_value, _pipe}.
-file("src/cake/where.gleam", 119).
?DOC(" Negates a `Where`.\n").
-spec 'not'(cake@internal@read_query:where()) -> cake@internal@read_query:where().
'not'(Whr) ->
_pipe = Whr,
{not_where, _pipe}.
-file("src/cake/where.gleam", 125).
?DOC(" Logical AND of multiple `Where`s.\n").
-spec 'and'(list(cake@internal@read_query:where())) -> cake@internal@read_query:where().
'and'(Whrs) ->
_pipe = Whrs,
{and_where, _pipe}.
-file("src/cake/where.gleam", 131).
?DOC(" Logical OR of multiple `Where`s.\n").
-spec 'or'(list(cake@internal@read_query:where())) -> cake@internal@read_query:where().
'or'(Whrs) ->
_pipe = Whrs,
{or_where, _pipe}.
-file("src/cake/where.gleam", 137).
?DOC(" Logical XOR of multiple `Where`s.\n").
-spec 'xor'(list(cake@internal@read_query:where())) -> cake@internal@read_query:where().
'xor'(Whrs) ->
_pipe = Whrs,
{xor_where, _pipe}.
-file("src/cake/where.gleam", 143).
?DOC(" No where condition.\n").
-spec none() -> cake@internal@read_query:where().
none() ->
no_where.
-file("src/cake/where.gleam", 148).
?DOC(" Creates a `WHERE` clause that checks if a `WhereValue` matches a `Bool`.\n").
-spec is_bool(cake@internal@read_query:where_value(), boolean()) -> cake@internal@read_query:where().
is_bool(Vl, B) ->
_pipe = Vl,
{where_is_bool, _pipe, B}.
-file("src/cake/where.gleam", 154).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` does not match a\n"
" `Bool`.\n"
).
-spec is_not_bool(cake@internal@read_query:where_value(), boolean()) -> cake@internal@read_query:where().
is_not_bool(Vl, B) ->
_pipe = Vl,
{where_is_not_bool, _pipe, B}.
-file("src/cake/where.gleam", 159).
?DOC(" Creates a `WHERE` clause that checks if a `WhereValue` is `False`.\n").
-spec is_false(cake@internal@read_query:where_value()) -> cake@internal@read_query:where().
is_false(Vl) ->
_pipe = Vl,
{where_is_bool, _pipe, false}.
-file("src/cake/where.gleam", 164).
?DOC(" Creates a `WHERE` clause that checks if a `WhereValue` is `True`.\n").
-spec is_true(cake@internal@read_query:where_value()) -> cake@internal@read_query:where().
is_true(Vl) ->
_pipe = Vl,
{where_is_bool, _pipe, true}.
-file("src/cake/where.gleam", 170).
?DOC(" Creates a `WHERE` clause that checks if a `WhereValue` is SQL `NULL`.\n").
-spec is_null(cake@internal@read_query:where_value()) -> cake@internal@read_query:where().
is_null(Vl) ->
_pipe = Vl,
{where_is_null, _pipe}.
-file("src/cake/where.gleam", 176).
?DOC(" Creates a `WHERE` clause that checks if a `WhereValue` is not SQL `NULL`.\n").
-spec is_not_null(cake@internal@read_query:where_value()) -> cake@internal@read_query:where().
is_not_null(Vl) ->
_pipe = Vl,
{where_is_not_null, _pipe}.
-file("src/cake/where.gleam", 183).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` equals another\n"
" `WhereValue`.\n"
).
-spec eq(
cake@internal@read_query:where_value(),
cake@internal@read_query:where_value()
) -> cake@internal@read_query:where().
eq(Vl_a, Vl_b) ->
_pipe = Vl_a,
{where_comparison, _pipe, equal, Vl_b}.
-file("src/cake/where.gleam", 190).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` lower than another\n"
" `WhereValue`.\n"
).
-spec lt(
cake@internal@read_query:where_value(),
cake@internal@read_query:where_value()
) -> cake@internal@read_query:where().
lt(Vl_a, Vl_b) ->
_pipe = Vl_a,
{where_comparison, _pipe, lower, Vl_b}.
-file("src/cake/where.gleam", 197).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` lower or equal to\n"
" another `WhereValue`.\n"
).
-spec lte(
cake@internal@read_query:where_value(),
cake@internal@read_query:where_value()
) -> cake@internal@read_query:where().
lte(Vl_a, Vl_b) ->
_pipe = Vl_a,
{where_comparison, _pipe, lower_or_equal, Vl_b}.
-file("src/cake/where.gleam", 204).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is greater than\n"
" another `WhereValue`.\n"
).
-spec gt(
cake@internal@read_query:where_value(),
cake@internal@read_query:where_value()
) -> cake@internal@read_query:where().
gt(Vl_a, Vl_b) ->
_pipe = Vl_a,
{where_comparison, _pipe, greater, Vl_b}.
-file("src/cake/where.gleam", 211).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is greater or equal\n"
" to another `WhereValue`.\n"
).
-spec gte(
cake@internal@read_query:where_value(),
cake@internal@read_query:where_value()
) -> cake@internal@read_query:where().
gte(Vl_a, Vl_b) ->
_pipe = Vl_a,
{where_comparison, _pipe, greater_or_equal, Vl_b}.
-file("src/cake/where.gleam", 220).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` matches any\n"
" in a sub-query.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec eq_any_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
eq_any_query(Vl, Qry) ->
_pipe = Vl,
{where_any_of_sub_query, _pipe, equal, Qry}.
-file("src/cake/where.gleam", 229).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is lower than an any\n"
" in a sub-query.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec lt_any_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
lt_any_query(Vl, Qry) ->
_pipe = Vl,
{where_any_of_sub_query, _pipe, lower, Qry}.
-file("src/cake/where.gleam", 238).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is lower or equal to\n"
" any in a sub-query.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec lte_any_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
lte_any_query(Vl, Qry) ->
_pipe = Vl,
{where_any_of_sub_query, _pipe, lower_or_equal, Qry}.
-file("src/cake/where.gleam", 247).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is greater than any\n"
" in a sub-query.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec gt_any_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
gt_any_query(Vl, Qry) ->
_pipe = Vl,
{where_any_of_sub_query, _pipe, greater, Qry}.
-file("src/cake/where.gleam", 256).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is greater or equal\n"
" to any in a sub-query.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec gte_any_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
gte_any_query(Vl, Qry) ->
_pipe = Vl,
{where_any_of_sub_query, _pipe, greater_or_equal, Qry}.
-file("src/cake/where.gleam", 265).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` matches all\n"
" in a sub-query.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec eq_all_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
eq_all_query(Vl, Qry) ->
_pipe = Vl,
{where_all_of_sub_query, _pipe, equal, Qry}.
-file("src/cake/where.gleam", 274).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is lower than all\n"
" in a sub-query.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec lt_all_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
lt_all_query(Vl, Qry) ->
_pipe = Vl,
{where_all_of_sub_query, _pipe, lower, Qry}.
-file("src/cake/where.gleam", 283).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is lower or equal to\n"
" all in a sub-query.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec lte_all_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
lte_all_query(Vl, Qry) ->
_pipe = Vl,
{where_all_of_sub_query, _pipe, lower_or_equal, Qry}.
-file("src/cake/where.gleam", 292).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is greater than all\n"
" in a sub-query.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec gt_all_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
gt_all_query(Vl, Qry) ->
_pipe = Vl,
{where_all_of_sub_query, _pipe, greater, Qry}.
-file("src/cake/where.gleam", 301).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is greater or equal\n"
" to all in a sub-query.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec gte_all_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
gte_all_query(Vl, Qry) ->
_pipe = Vl,
{where_all_of_sub_query, _pipe, greater_or_equal, Qry}.
-file("src/cake/where.gleam", 309).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is IN a sub-query.\n"
"\n"
" NOTICE: Usually the sub-query must return a single column.\n"
).
-spec in_query(
cake@internal@read_query:where_value(),
cake@internal@read_query:read_query()
) -> cake@internal@read_query:where().
in_query(Vl, Qry) ->
_pipe = Vl,
{where_in,
_pipe,
[begin
_pipe@1 = Qry,
{where_sub_query_value, _pipe@1}
end]}.
-file("src/cake/where.gleam", 316).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is in a list of\n"
" `WhereValue`s.\n"
).
-spec in(
cake@internal@read_query:where_value(),
list(cake@internal@read_query:where_value())
) -> cake@internal@read_query:where().
in(Vl, Vals) ->
_pipe = Vl,
{where_in, _pipe, Vals}.
-file("src/cake/where.gleam", 322).
?DOC(" Creates a `WHERE` clause that checks if it exists in a sub-query.\n").
-spec exists_in_query(cake@internal@read_query:read_query()) -> cake@internal@read_query:where().
exists_in_query(Qry) ->
_pipe = Qry,
{where_exists_in_sub_query, _pipe}.
-file("src/cake/where.gleam", 334).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` A is between two\n"
" `WhereValue`s B and C.\n"
).
-spec between(
cake@internal@read_query:where_value(),
cake@internal@read_query:where_value(),
cake@internal@read_query:where_value()
) -> cake@internal@read_query:where().
between(Vl_a, Vl_b, Vl_c) ->
_pipe = Vl_a,
{where_between, _pipe, Vl_b, Vl_c}.
-file("src/cake/where.gleam", 348).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` matches a pattern.\n"
" The pattern can contain for example the following wildcards:\n"
"\n"
" - `%` matches any sequence of characters.\n"
" - `_` matches any single character.\n"
).
-spec like(cake@internal@read_query:where_value(), binary()) -> cake@internal@read_query:where().
like(Vl, Pttrn) ->
_pipe = Vl,
{where_like, _pipe, Pttrn}.
-file("src/cake/where.gleam", 356).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` matches a pattern.\n"
"\n"
" `ilike` is the same as `like` but case-insensitive.\n"
).
-spec ilike(cake@internal@read_query:where_value(), binary()) -> cake@internal@read_query:where().
ilike(Vl, Pttrn) ->
_pipe = Vl,
{where_i_like, _pipe, Pttrn}.
-file("src/cake/where.gleam", 365).
?DOC(
" Creates a `WHERE` clause that checks if a `WhereValue` is similar to a\n"
" pattern.\n"
"\n"
" NOTICE: Not supported by 🪶SQLite.\n"
).
-spec similar_to(cake@internal@read_query:where_value(), binary(), binary()) -> cake@internal@read_query:where().
similar_to(Vl, Pttrn, Escp_char) ->
_pipe = Vl,
{where_similar_to, _pipe, Pttrn, Escp_char}.
-file("src/cake/where.gleam", 375).
?DOC(" Creates a `WhereFragment` from a `Fragment`.\n").
-spec fragment(cake@internal@read_query:fragment()) -> cake@internal@read_query:where().
fragment(Frgmt) ->
_pipe = Frgmt,
{where_fragment, _pipe}.