-module(cake@combined). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/cake/combined.gleam"). -export([to_query/1, union/2, unions/3, union_all/2, unions_all/3, except/2, excepts/3, except_all/2, excepts_all/3, intersect/2, intersects/3, intersect_all/2, intersects_all/3, get_queries/1, limit/2, no_limit/1, get_limit/1, offset/2, no_offset/1, get_offset/1, order_by_asc/2, order_by_asc_nulls_first/2, order_by_asc_nulls_last/2, replace_order_by_asc/2, replace_order_by_asc_nulls_first/2, replace_order_by_asc_nulls_last/2, order_by_desc/2, order_by_desc_nulls_first/2, order_by_desc_nulls_last/2, replace_order_by_desc/2, replace_order_by_desc_nulls_first/2, replace_order_by_desc_nulls_last/2, order_by/3, replace_order_by/3, no_order_by/1, get_order_by/1, epilog/2, no_epilog/1, get_epilog/1, comment/2, no_comment/1, get_comment/1]). -export_type([direction/0]). -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( " A DSL to build combined queries, such as:\n" "\n" " - `UNION`\n" " - `UNION ALL`\n" " - `EXCEPT`\n" " - `EXCEPT ALL`\n" " - `INTERSECT`\n" " - `INTERSECT ALL`\n" "\n" " ## Aliases\n" "\n" " ```gleam\n" " import cake/combined as c\n" " import cake/select as s\n" " import cake/where as w\n" " ```\n" "\n" " ---\n" "\n" " ## Query Lifecycle\n" "\n" " ```mermaid\n" " flowchart LR\n" " A[s.new + query builders] --> B{set operation}\n" " B -->|union| C[c.union / c.unions]\n" " B -->|union_all| D[c.union_all / c.unions_all]\n" " B -->|except| E[c.except / c.excepts]\n" " B -->|except_all| F[c.except_all / c.excepts_all]\n" " B -->|intersect| G[c.intersect / c.intersects]\n" " B -->|intersect_all| H[c.intersect_all / c.intersects_all]\n" " C --> I[limit / offset / order_by]\n" " D --> I\n" " E --> I\n" " F --> I\n" " G --> I\n" " H --> I\n" " I --> J[c.epilog / c.comment]\n" " J --> K[c.to_query]\n" " ```\n" "\n" " ---\n" "\n" " ## Set Operations\n" "\n" " All set operations take at least two `Select` queries (converted via\n" " `s.to_query`) and return a `Combined` value. The `_all` variants accept\n" " two queries; the plural variants accept a list of additional queries.\n" "\n" " ### `union(a, b) -> Combined` / `unions(a, b, rest) -> Combined`\n" "\n" " `UNION` — distinct rows from both queries.\n" "\n" " ```gleam\n" " let q1 =\n" " s.new()\n" " |> s.from_table(\"users\")\n" " |> s.col(\"name\")\n" " |> s.to_query\n" "\n" " let q2 =\n" " s.new()\n" " |> s.from_table(\"customers\")\n" " |> s.col(\"name\")\n" " |> s.to_query\n" "\n" " c.union(q1, q2)\n" " // SELECT name FROM users UNION SELECT name FROM customers\n" " ```\n" "\n" " ### `union_all(a, b) -> Combined` / `unions_all(a, b, rest) -> Combined`\n" "\n" " `UNION ALL` — all rows from both queries (no deduplication).\n" "\n" " ```gleam\n" " c.union_all(q1, q2)\n" " // SELECT name FROM users UNION ALL SELECT name FROM customers\n" " ```\n" "\n" " ### `except(a, b) -> Combined` / `excepts(a, b, rest) -> Combined`\n" "\n" " `EXCEPT` — rows in the first query that do not appear in the second.\n" "\n" " ```gleam\n" " c.except(q1, q2)\n" " // SELECT name FROM users EXCEPT SELECT name FROM customers\n" " ```\n" "\n" " ### `except_all(a, b) -> Combined` / `excepts_all(a, b, rest) -> Combined`\n" "\n" " `EXCEPT ALL` — rows in the first query that do not appear in the second,\n" " including duplicates.\n" "\n" " > Not supported by 🪶 SQLite.\n" "\n" " ```gleam\n" " c.except_all(q1, q2)\n" " // SELECT name FROM users EXCEPT ALL SELECT name FROM customers\n" " ```\n" "\n" " ### `intersect(a, b) -> Combined` / `intersects(a, b, rest) -> Combined`\n" "\n" " `INTERSECT` — rows that appear in both queries.\n" "\n" " ```gleam\n" " c.intersect(q1, q2)\n" " // SELECT name FROM users INTERSECT SELECT name FROM customers\n" " ```\n" "\n" " ### `intersect_all(a, b) -> Combined` / `intersects_all(a, b, rest) -> Combined`\n" "\n" " `INTERSECT ALL` — rows that appear in both queries, including duplicates.\n" "\n" " > Not supported by 🪶 SQLite.\n" "\n" " ```gleam\n" " c.intersect_all(q1, q2)\n" " // SELECT name FROM users INTERSECT ALL SELECT name FROM customers\n" " ```\n" "\n" " ---\n" "\n" " ## Helper\n" "\n" " ### `get_queries(combined) -> List(Select)`\n" "\n" " Extracts the original `Select` queries from a `Combined` value.\n" "\n" " ```gleam\n" " c.get_queries(combined_query)\n" " ```\n" "\n" " ---\n" "\n" " ## LIMIT & OFFSET\n" "\n" " Applied to the result of the combined query (not to individual sub-queries).\n" "\n" " | Function | Effect |\n" " | ------ | ------ |\n" " | `limit(query, n)` | Set LIMIT |\n" " | `no_limit(query)` | Remove LIMIT |\n" " | `get_limit(query)` | Get current LIMIT |\n" " | `offset(query, n)` | Set OFFSET |\n" " | `no_offset(query)` | Remove OFFSET |\n" " | `get_offset(query)` | Get current OFFSET |\n" "\n" " ```gleam\n" " c.union(q1, q2)\n" " |> c.limit(10)\n" " |> c.offset(20)\n" " ```\n" "\n" " ---\n" "\n" " ## ORDER BY\n" "\n" " Sorts the combined result set.\n" "\n" " ### Direction\n" "\n" " | Constructor | Description |\n" " | --- | --- |\n" " | `c.Asc` | Ascending |\n" " | `c.Desc` | Descending |\n" "\n" " ### Appending\n" "\n" " | Function | Notes |\n" " | --- | --- |\n" " | `order_by_asc(query, col)` | Append ASC |\n" " | `order_by_asc_nulls_first(query, col)` | ASC NULLS FIRST |\n" " | `order_by_asc_nulls_last(query, col)` | ASC NULLS LAST |\n" " | `order_by_desc(query, col)` | Append DESC |\n" " | `order_by_desc_nulls_first(query, col)` | DESC NULLS FIRST |\n" " | `order_by_desc_nulls_last(query, col)` | DESC NULLS LAST |\n" " | `order_by(query, col, direction)` | Custom direction |\n" "\n" " ### Replacing\n" "\n" " | Function | Notes |\n" " | --- | --- |\n" " | `replace_order_by_asc(query, col)` | Replace all with ASC |\n" " | `replace_order_by_asc_nulls_first(query, col)` | Replace with ASC NULLS FIRST |\n" " | `replace_order_by_asc_nulls_last(query, col)` | Replace with ASC NULLS LAST |\n" " | `replace_order_by_desc(query, col)` | Replace all with DESC |\n" " | `replace_order_by_desc_nulls_first(query, col)` | Replace with DESC NULLS FIRST |\n" " | `replace_order_by_desc_nulls_last(query, col)` | Replace with DESC NULLS LAST |\n" " | `replace_order_by(query, col, direction)` | Replace with custom direction |\n" "\n" " ### Removal / retrieval\n" "\n" " | Function | Effect |\n" " | --- | --- |\n" " | `no_order_by(query)` | Remove ORDER BY |\n" " | `get_order_by(query)` | Get current ORDER BY |\n" "\n" " > **Note:** `NULLS FIRST` / `NULLS LAST` are not supported out of the box by\n" " > 🦭 MariaDB or 🐬 MySQL.\n" "\n" " ```gleam\n" " c.union(q1, q2)\n" " |> c.order_by_desc(\"name\")\n" " // SELECT ... UNION SELECT ... ORDER BY name DESC\n" " ```\n" "\n" " ---\n" "\n" " ## Epilog and Comment\n" "\n" " An **epilog** is appended verbatim to the end of the generated SQL.\n" " A **comment** is placed at the very end as a SQL `--` comment.\n" "\n" " | Function | Effect |\n" " | --- | --- |\n" " | `epilog(query, text)` | Append epilog |\n" " | `no_epilog(query)` | Remove epilog |\n" " | `get_epilog(query)` | Get current epilog |\n" " | `comment(query, text)` | Append comment |\n" " | `no_comment(query)` | Remove comment |\n" " | `get_comment(query)` | Get current comment |\n" "\n" " ```gleam\n" " c.union(q1, q2)\n" " |> c.epilog(\"FOR UPDATE\")\n" " |> c.comment(\"fetching locked rows\")\n" " // SELECT ... UNION SELECT ... FOR UPDATE -- fetching locked rows\n" " ```\n" "\n" " ---\n" "\n" " ## Converting to a Query\n" "\n" " ### `to_query(combined) -> ReadQuery`\n" "\n" " Converts a `Combined` into a `ReadQuery` suitable for passing to an adapter.\n" "\n" " ```gleam\n" " c.union(q1, q2)\n" " |> c.limit(10)\n" " |> c.to_query\n" " ```\n" "\n" " ---\n" "\n" " ## Full Example\n" "\n" " ```gleam\n" " import cake/combined as c\n" " import cake/select as s\n" " import cake/where as w\n" "\n" " let active_users =\n" " s.new()\n" " |> s.from_table(\"users\")\n" " |> s.select_cols([\"id\", \"name\", \"active\"])\n" " |> s.where(w.eq(w.col(\"active\"), w.bool(True)))\n" " |> s.to_query\n" "\n" " let active_customers =\n" " s.new()\n" " |> s.from_table(\"customers\")\n" " |> s.select_cols([\"id\", \"name\", \"active\"])\n" " |> s.where(w.eq(w.col(\"active\"), w.bool(True)))\n" " |> s.to_query\n" "\n" " c.unions(active_users, active_customers, [\n" " s.new()\n" " |> s.from_table(\"admins\")\n" " |> s.select_cols([\"id\", \"name\", \"active\"])\n" " |> s.where(w.eq(w.col(\"active\"), w.bool(True)))\n" " |> s.to_query,\n" " ])\n" " |> c.order_by_asc(\"name\")\n" " |> c.limit(50)\n" " |> c.to_query\n" " // (SELECT id, name, active FROM users WHERE active = $1)\n" " // UNION\n" " // (SELECT id, name, active FROM customers WHERE active = $2)\n" " // UNION\n" " // (SELECT id, name, active FROM admins WHERE active = $3)\n" " // ORDER BY name ASC\n" " // LIMIT 50\n" " ```\n" "\n" "\n" " \n" " \n" " \n" " \n" " \n" "\n" ). -type direction() :: asc | desc. -file("src/cake/combined.gleam", 352). ?DOC(" Creates a `ReadQuery` from a `Combined` `ReadQuery`.\n"). -spec to_query(cake@internal@read_query:combined()) -> cake@internal@read_query:read_query(). to_query(Combined) -> _pipe = Combined, {combined_query, _pipe}. -file("src/cake/combined.gleam", 360). ?DOC(" Creates a `UNION` query out of two queries as a `Combined` `ReadQuery`.\n"). -spec union( cake@internal@read_query:select(), cake@internal@read_query:select() ) -> cake@internal@read_query:combined(). union(Query_a, Query_b) -> _pipe = union_distinct, cake@internal@read_query:combined_query_new(_pipe, [Query_a, Query_b]). -file("src/cake/combined.gleam", 367). ?DOC( " Creates a `UNION` query out of two or more queries as a `Combined`\n" " `ReadQuery`.\n" ). -spec unions( cake@internal@read_query:select(), cake@internal@read_query:select(), list(cake@internal@read_query:select()) ) -> cake@internal@read_query:combined(). unions(Query_a, Query_b, More_queries) -> _pipe = union_distinct, cake@internal@read_query:combined_query_new( _pipe, [Query_a, Query_b | More_queries] ). -file("src/cake/combined.gleam", 378). ?DOC(" Creates a `UNION ALL` query out of two queries as a `Combined` `ReadQuery`.\n"). -spec union_all( cake@internal@read_query:select(), cake@internal@read_query:select() ) -> cake@internal@read_query:combined(). union_all(Query_a, Query_b) -> _pipe = union_all, cake@internal@read_query:combined_query_new(_pipe, [Query_a, Query_b]). -file("src/cake/combined.gleam", 385). ?DOC( " Creates a `UNION ALL` query out of two or more queries as a `Combined`\n" " `ReadQuery`.\n" ). -spec unions_all( cake@internal@read_query:select(), cake@internal@read_query:select(), list(cake@internal@read_query:select()) ) -> cake@internal@read_query:combined(). unions_all(Query_a, Query_b, More_queries) -> _pipe = union_all, cake@internal@read_query:combined_query_new( _pipe, [Query_a, Query_b | More_queries] ). -file("src/cake/combined.gleam", 396). ?DOC(" Creates an `EXCEPT` query out of two queries as a `Combined` `ReadQuery`.\n"). -spec except( cake@internal@read_query:select(), cake@internal@read_query:select() ) -> cake@internal@read_query:combined(). except(Query_a, Query_b) -> _pipe = except_distinct, cake@internal@read_query:combined_query_new(_pipe, [Query_a, Query_b]). -file("src/cake/combined.gleam", 403). ?DOC( " Creates an `EXCEPT` query out of two or more queries as a `Combined`\n" " `ReadQuery`.\n" ). -spec excepts( cake@internal@read_query:select(), cake@internal@read_query:select(), list(cake@internal@read_query:select()) ) -> cake@internal@read_query:combined(). excepts(Query_a, Query_b, More_queries) -> _pipe = except_distinct, cake@internal@read_query:combined_query_new( _pipe, [Query_a, Query_b | More_queries] ). -file("src/cake/combined.gleam", 417). ?DOC( " Creates an `EXCEPT ALL` query out of two queries as a `Combined`\n" " `ReadQuery`.\n" "\n" " NOTICE: Not supported by 🪶SQLite.\n" ). -spec except_all( cake@internal@read_query:select(), cake@internal@read_query:select() ) -> cake@internal@read_query:combined(). except_all(Query_a, Query_b) -> _pipe = except_all, cake@internal@read_query:combined_query_new(_pipe, [Query_a, Query_b]). -file("src/cake/combined.gleam", 429). ?DOC( " Creates an `EXCEPT ALL` query out of two or more queries as a `Combined`\n" " `ReadQuery`.\n" "\n" " NOTICE: Not supported by 🪶SQLite.\n" ). -spec excepts_all( cake@internal@read_query:select(), cake@internal@read_query:select(), list(cake@internal@read_query:select()) ) -> cake@internal@read_query:combined(). excepts_all(Query_a, Query_b, More_queries) -> _pipe = except_all, cake@internal@read_query:combined_query_new( _pipe, [Query_a, Query_b | More_queries] ). -file("src/cake/combined.gleam", 440). ?DOC(" Creates an `INTERSECT` query out of two queries as a `Combined` `ReadQuery`.\n"). -spec intersect( cake@internal@read_query:select(), cake@internal@read_query:select() ) -> cake@internal@read_query:combined(). intersect(Query_a, Query_b) -> _pipe = intersect_distinct, cake@internal@read_query:combined_query_new(_pipe, [Query_a, Query_b]). -file("src/cake/combined.gleam", 448). ?DOC( " Creates an `INTERSECT` query out of two or more queries as a `Combined`\n" " `ReadQuery`.\n" ). -spec intersects( cake@internal@read_query:select(), cake@internal@read_query:select(), list(cake@internal@read_query:select()) ) -> cake@internal@read_query:combined(). intersects(Query_a, Query_b, More_queries) -> _pipe = intersect_distinct, cake@internal@read_query:combined_query_new( _pipe, [Query_a, Query_b | More_queries] ). -file("src/cake/combined.gleam", 462). ?DOC( " Creates an `INTERSECT ALL` query out of two queries as a `Combined`\n" " `ReadQuery`.\n" "\n" " NOTICE: Not supported by 🪶SQLite.\n" ). -spec intersect_all( cake@internal@read_query:select(), cake@internal@read_query:select() ) -> cake@internal@read_query:combined(). intersect_all(Query_a, Query_b) -> _pipe = intersect_all, cake@internal@read_query:combined_query_new(_pipe, [Query_a, Query_b]). -file("src/cake/combined.gleam", 474). ?DOC( " Creates an `INTERSECT ALL` query out of two or more queries as a `Combined`\n" " `ReadQuery`.\n" "\n" " NOTICE: Not supported by 🪶SQLite.\n" ). -spec intersects_all( cake@internal@read_query:select(), cake@internal@read_query:select(), list(cake@internal@read_query:select()) ) -> cake@internal@read_query:combined(). intersects_all(Query_a, Query_b, More_queries) -> _pipe = intersect_all, cake@internal@read_query:combined_query_new( _pipe, [Query_a, Query_b | More_queries] ). -file("src/cake/combined.gleam", 485). ?DOC(" Gets the queries from a `Combined` `ReadQuery`.\n"). -spec get_queries(cake@internal@read_query:combined()) -> list(cake@internal@read_query:select()). get_queries(Combined) -> erlang:element(3, Combined). -file("src/cake/combined.gleam", 493). ?DOC(" Sets a `Limit` in the `Combined` `ReadQuery`.\n"). -spec limit(cake@internal@read_query:combined(), integer()) -> cake@internal@read_query:combined(). limit(Query, Limit) -> Limit@1 = cake@internal@read_query:limit_new(Limit), {combined, erlang:element(2, Query), erlang:element(3, Query), Limit@1, erlang:element(5, Query), erlang:element(6, Query), erlang:element(7, Query), erlang:element(8, Query)}. -file("src/cake/combined.gleam", 500). ?DOC(" Removes `Limit` from the `Combined` `ReadQuery`.\n"). -spec no_limit(cake@internal@read_query:combined()) -> cake@internal@read_query:combined(). no_limit(Query) -> {combined, erlang:element(2, Query), erlang:element(3, Query), no_limit, erlang:element(5, Query), erlang:element(6, Query), erlang:element(7, Query), erlang:element(8, Query)}. -file("src/cake/combined.gleam", 506). ?DOC(" Gets `Limit` in the `Combined` `ReadQuery`.\n"). -spec get_limit(cake@internal@read_query:combined()) -> cake@internal@read_query:limit(). get_limit(Query) -> erlang:element(4, Query). -file("src/cake/combined.gleam", 512). ?DOC(" Sets an `Offset` in the `Combined` `ReadQuery`.\n"). -spec offset(cake@internal@read_query:combined(), integer()) -> cake@internal@read_query:combined(). offset(Query, Offset) -> Offset@1 = cake@internal@read_query:offset_new(Offset), {combined, erlang:element(2, Query), erlang:element(3, Query), erlang:element(4, Query), Offset@1, erlang:element(6, Query), erlang:element(7, Query), erlang:element(8, Query)}. -file("src/cake/combined.gleam", 519). ?DOC(" Removes `Offset` from the `Combined` `ReadQuery`.\n"). -spec no_offset(cake@internal@read_query:combined()) -> cake@internal@read_query:combined(). no_offset(Query) -> {combined, erlang:element(2, Query), erlang:element(3, Query), erlang:element(4, Query), no_offset, erlang:element(6, Query), erlang:element(7, Query), erlang:element(8, Query)}. -file("src/cake/combined.gleam", 525). ?DOC(" Gets `Offset` in the `Combined` `ReadQuery`.\n"). -spec get_offset(cake@internal@read_query:combined()) -> cake@internal@read_query:offset(). get_offset(Query) -> erlang:element(5, Query). -file("src/cake/combined.gleam", 538). -spec map_order_by_direction_constructor(direction()) -> cake@internal@read_query:order_by_direction(). map_order_by_direction_constructor(In) -> case In of asc -> asc; desc -> desc end. -file("src/cake/combined.gleam", 547). ?DOC(" Creates or appends an ascending `OrderBy`.\n"). -spec order_by_asc(cake@internal@read_query:combined(), binary()) -> cake@internal@read_query:combined(). order_by_asc(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, asc} end], {order_by, _pipe@2} end, true ). -file("src/cake/combined.gleam", 562). ?DOC( " Creates or appends an ascending `OrderBy` with `NULLS FIRST`.\n" "\n" " NOTICE: 🦭MariaDB and 🐬MySQL do not support `NULLS FIRST` out of the box.\n" ). -spec order_by_asc_nulls_first(cake@internal@read_query:combined(), binary()) -> cake@internal@read_query:combined(). order_by_asc_nulls_first(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, asc_nulls_first} end], {order_by, _pipe@2} end, true ). -file("src/cake/combined.gleam", 577). ?DOC( " Creates or appends an ascending `OrderBy` with `NULLS LAST`.\n" "\n" " NOTICE: 🦭MariaDB and 🐬MySQL do not support `NULLS LAST` out of the box.\n" ). -spec order_by_asc_nulls_last(cake@internal@read_query:combined(), binary()) -> cake@internal@read_query:combined(). order_by_asc_nulls_last(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, asc_nulls_last} end], {order_by, _pipe@2} end, true ). -file("src/cake/combined.gleam", 590). ?DOC(" Replaces the `OrderBy` with a single ascending `OrderBy`.\n"). -spec replace_order_by_asc(cake@internal@read_query:combined(), binary()) -> cake@internal@read_query:combined(). replace_order_by_asc(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, asc} end], {order_by, _pipe@2} end, false ). -file("src/cake/combined.gleam", 605). ?DOC( " Replaces the `OrderBy` with a single ascending `OrderBy` with `NULLS FIRST`.\n" "\n" " NOTICE: 🦭MariaDB and 🐬MySQL do not support `NULLS FIRST` out of the box.\n" ). -spec replace_order_by_asc_nulls_first( cake@internal@read_query:combined(), binary() ) -> cake@internal@read_query:combined(). replace_order_by_asc_nulls_first(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, asc_nulls_first} end], {order_by, _pipe@2} end, false ). -file("src/cake/combined.gleam", 620). ?DOC( " Replaces the `OrderBy` with a single ascending `OrderBy` with `NULLS LAST`.\n" "\n" " NOTICE: 🦭MariaDB and 🐬MySQL do not support `NULLS LAST` out of the box.\n" ). -spec replace_order_by_asc_nulls_last( cake@internal@read_query:combined(), binary() ) -> cake@internal@read_query:combined(). replace_order_by_asc_nulls_last(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, asc_nulls_last} end], {order_by, _pipe@2} end, false ). -file("src/cake/combined.gleam", 633). ?DOC(" Creates or appends a descending `OrderBy`.\n"). -spec order_by_desc(cake@internal@read_query:combined(), binary()) -> cake@internal@read_query:combined(). order_by_desc(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, desc} end], {order_by, _pipe@2} end, true ). -file("src/cake/combined.gleam", 648). ?DOC( " Creates or appends a descending order with `NULLS FIRST`.\n" "\n" " NOTICE: 🦭MariaDB and 🐬MySQL do not support `NULLS FIRST` out of the box.\n" ). -spec order_by_desc_nulls_first(cake@internal@read_query:combined(), binary()) -> cake@internal@read_query:combined(). order_by_desc_nulls_first(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, desc_nulls_first} end], {order_by, _pipe@2} end, true ). -file("src/cake/combined.gleam", 663). ?DOC( " Creates or appends a descending `OrderBy` with `NULLS LAST`.\n" "\n" " NOTICE: 🦭MariaDB and 🐬MySQL do not support `NULLS LAST` out of the box.\n" ). -spec order_by_desc_nulls_last(cake@internal@read_query:combined(), binary()) -> cake@internal@read_query:combined(). order_by_desc_nulls_last(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, desc_nulls_last} end], {order_by, _pipe@2} end, true ). -file("src/cake/combined.gleam", 676). ?DOC(" Replaces the `OrderBy` with a single descending order.\n"). -spec replace_order_by_desc(cake@internal@read_query:combined(), binary()) -> cake@internal@read_query:combined(). replace_order_by_desc(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, desc} end], {order_by, _pipe@2} end, false ). -file("src/cake/combined.gleam", 691). ?DOC( " Replaces the `OrderBy` with a single descending order with `NULLS FIRST`.\n" "\n" " NOTICE: 🦭MariaDB and 🐬MySQL do not support `NULLS FIRST` out of the box.\n" ). -spec replace_order_by_desc_nulls_first( cake@internal@read_query:combined(), binary() ) -> cake@internal@read_query:combined(). replace_order_by_desc_nulls_first(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, desc_nulls_first} end], {order_by, _pipe@2} end, false ). -file("src/cake/combined.gleam", 706). ?DOC( " Replaces the `OrderBy` with a single descending `OrderBy` with `NULLS LAST`.\n" "\n" " NOTICE: 🦭MariaDB and 🐬MySQL do not support `NULLS LAST` out of the box.\n" ). -spec replace_order_by_desc_nulls_last( cake@internal@read_query:combined(), binary() ) -> cake@internal@read_query:combined(). replace_order_by_desc_nulls_last(Query, Order_by) -> _pipe = Query, cake@internal@read_query:combined_order_by( _pipe, begin _pipe@2 = [begin _pipe@1 = Order_by, {order_by_column, _pipe@1, desc_nulls_last} end], {order_by, _pipe@2} end, false ). -file("src/cake/combined.gleam", 721). ?DOC( " Creates or appends an `OrderBy` for a column with a direction.\n" "\n" " The direction can either `ASC` or `DESC`.\n" ). -spec order_by(cake@internal@read_query:combined(), binary(), direction()) -> cake@internal@read_query:combined(). order_by(Query, Order_by, Direction) -> Direction@1 = begin _pipe = Direction, map_order_by_direction_constructor(_pipe) end, _pipe@1 = Query, cake@internal@read_query:combined_order_by( _pipe@1, begin _pipe@3 = [begin _pipe@2 = Order_by, {order_by_column, _pipe@2, Direction@1} end], {order_by, _pipe@3} end, true ). -file("src/cake/combined.gleam", 736). ?DOC(" Replaces the `OrderBy` with a column with a direction.\n"). -spec replace_order_by( cake@internal@read_query:combined(), binary(), direction() ) -> cake@internal@read_query:combined(). replace_order_by(Query, Order_by, Direction) -> Direction@1 = begin _pipe = Direction, map_order_by_direction_constructor(_pipe) end, _pipe@1 = Query, cake@internal@read_query:combined_order_by( _pipe@1, begin _pipe@3 = [begin _pipe@2 = Order_by, {order_by_column, _pipe@2, Direction@1} end], {order_by, _pipe@3} end, false ). -file("src/cake/combined.gleam", 751). ?DOC(" Removes the `OrderBy` from the `Combined` read_query.\n"). -spec no_order_by(cake@internal@read_query:combined()) -> cake@internal@read_query:combined(). no_order_by(Query) -> {combined, erlang:element(2, Query), erlang:element(3, Query), erlang:element(4, Query), erlang:element(5, Query), no_order_by, erlang:element(7, Query), erlang:element(8, Query)}. -file("src/cake/combined.gleam", 757). ?DOC(" Gets the `OrderBy` from the `Combined` read_query.\n"). -spec get_order_by(cake@internal@read_query:combined()) -> cake@internal@read_query:order_by(). get_order_by(Query) -> erlang:element(6, Query). -file("src/cake/combined.gleam", 765). ?DOC(" Appends an `Epilog` to the `Combined` read_query.\n"). -spec epilog(cake@internal@read_query:combined(), binary()) -> cake@internal@read_query:combined(). epilog(Query, Epilog) -> Epilog@1 = begin _pipe = Epilog, gleam@string:trim(_pipe) end, case Epilog@1 of <<""/utf8>> -> {combined, erlang:element(2, Query), erlang:element(3, Query), erlang:element(4, Query), erlang:element(5, Query), erlang:element(6, Query), no_epilog, erlang:element(8, Query)}; _ -> {combined, erlang:element(2, Query), erlang:element(3, Query), erlang:element(4, Query), erlang:element(5, Query), erlang:element(6, Query), begin _pipe@1 = (<<" "/utf8, Epilog@1/binary>>), {epilog, _pipe@1} end, erlang:element(8, Query)} end. -file("src/cake/combined.gleam", 775). ?DOC(" Removes the `Epilog` from the `Combined` read_query.\n"). -spec no_epilog(cake@internal@read_query:combined()) -> cake@internal@read_query:combined(). no_epilog(Query) -> {combined, erlang:element(2, Query), erlang:element(3, Query), erlang:element(4, Query), erlang:element(5, Query), erlang:element(6, Query), no_epilog, erlang:element(8, Query)}. -file("src/cake/combined.gleam", 781). ?DOC(" Gets the `Epilog` from the `Combined` read_query.\n"). -spec get_epilog(cake@internal@read_query:combined()) -> cake@internal@read_query:epilog(). get_epilog(Query) -> erlang:element(7, Query). -file("src/cake/combined.gleam", 789). ?DOC(" Appends a `Comment` to the `Combined` read_query.\n"). -spec comment(cake@internal@read_query:combined(), binary()) -> cake@internal@read_query:combined(). comment(Query, Comment) -> Comment@1 = begin _pipe = Comment, gleam@string:trim(_pipe) end, case Comment@1 of <<""/utf8>> -> {combined, erlang:element(2, Query), erlang:element(3, Query), erlang:element(4, Query), erlang:element(5, Query), erlang:element(6, Query), erlang:element(7, Query), no_comment}; _ -> {combined, erlang:element(2, Query), erlang:element(3, Query), erlang:element(4, Query), erlang:element(5, Query), erlang:element(6, Query), erlang:element(7, Query), begin _pipe@1 = (<<" "/utf8, Comment@1/binary>>), {comment, _pipe@1} end} end. -file("src/cake/combined.gleam", 799). ?DOC(" Removes the `Comment` from the `Combined` read_query.\n"). -spec no_comment(cake@internal@read_query:combined()) -> cake@internal@read_query:combined(). no_comment(Query) -> {combined, erlang:element(2, Query), erlang:element(3, Query), erlang:element(4, Query), erlang:element(5, Query), erlang:element(6, Query), erlang:element(7, Query), no_comment}. -file("src/cake/combined.gleam", 805). ?DOC(" Gets the `Comment` from the `Combined` read_query.\n"). -spec get_comment(cake@internal@read_query:combined()) -> cake@internal@read_query:comment(). get_comment(Query) -> erlang:element(8, Query).