Skip to content

Commit

Permalink
todo
Browse files Browse the repository at this point in the history
  • Loading branch information
inoas committed Jun 22, 2024
1 parent 87a0b56 commit b42c740
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
9 changes: 5 additions & 4 deletions src/cake/internal/query.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

// TODO: Add to query validator in v2 or v3

// TODO v1 doc all public types, consts and functions in internal modules

import cake/dialect.{type Dialect, Maria, Postgres, Sqlite}
import cake/internal/prepared_statement.{type PreparedStatement}
import cake/param.{type Param}
Expand Down Expand Up @@ -1263,11 +1265,10 @@ pub fn comment_apply(
/// Fragments are used to insert raw SQL into the query.
///
/// NOTICE: Injecting input data into fragments is only safe when using
/// `FragmentPrepared` and only using literal strings in the `fragment`
/// field.
/// `FragmentPrepared` and only using literal strings in the `fragment` field.
///
/// As a strategy it is recommended to ALWAYS USE MODULE CONSTANTS for
/// any `fragment`-field string.
/// As a strategy it is recommended to ALWAYS USE MODULE CONSTANTS for
/// any `fragment`-field string.
///
pub type Fragment {
FragmentLiteral(fragment: String)
Expand Down
6 changes: 3 additions & 3 deletions src/cake/query/delete.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ pub fn or_where(query qry: Delete(a), where whr: Where) -> Delete(a) {
/// - If the outermost `Where` is any other kind of `Where`, this and the
/// current outermost `Where` are wrapped in an `XorWhere`.
///
/// NOTICE: This operator does not exist in Postgres or Sqlite,
/// and *Cake* generates equivalent SQL using `OR` and `AND` and `NOT`.
/// This operator exists in MariaDB/MySQL.
/// NOTICE: This operator does not exist in Postgres or Sqlite, and *Cake*
/// generates equivalent SQL using `OR` and `AND` and `NOT`.
/// This operator exists in MariaDB/MySQL.
///
pub fn xor_where(query qry: Delete(a), where whr: Where) -> Delete(a) {
case qry.where {
Expand Down
4 changes: 2 additions & 2 deletions src/cake/query/insert.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ pub fn get_source(query qry: Insert(a)) -> InsertSource(a) {
/// Specify the columns to insert into.
///
/// NOTICE: You have to specify the columns and keep track if their names are
/// correct, as well as their count which must be equal to the count of
/// `InsertRows` the caster function returns or is given as source
/// correct, as well as their count which must be equal to the count of
/// `InsertRows` the caster function returns or is given as source
/// values.
///
pub fn columns(query qry: Insert(a), columns cols: List(String)) -> Insert(a) {
Expand Down
14 changes: 7 additions & 7 deletions src/cake/query/select.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ pub fn or_where(query qry: Select, where whr: Where) -> Select {
/// current outermost `Where` are wrapped in an `XorWhere`.
///
/// NOTICE: This operator does not exist in Postgres or Sqlite,
/// and *Cake* generates equivalent SQL using `OR` and `AND` and `NOT`.
/// This operator exists in MariaDB/MySQL.
/// and *Cake* generates equivalent SQL using `OR` and `AND` and `NOT`.
/// This operator exists in MariaDB/MySQL.
///
pub fn xor_where(query qry: Select, where whr: Where) -> Select {
case qry.where {
Expand Down Expand Up @@ -334,9 +334,9 @@ pub fn get_where(query qry: Select) -> Where {
/// - If the outermost `Where` is any other kind of `Where`, this and the
/// current outermost `Where` are wrapped in an `AndWhere`.
///
/// NOTICE: `HAVING` allows to specify constraints much like `WHERE`,
/// but filters the results after `GROUP BY` is applied instead of
/// before. Because `HAVING` uses the same semantics as `WHERE`, it
/// NOTICE: `HAVING` allows to specify constraints much like `WHERE`, but
/// filters the results after `GROUP BY` is applied instead of before. Because
/// `HAVING` uses the same semantics as `WHERE`, it
/// takes a `Where`.
///
pub fn having(query qry: Select, having whr: Where) -> Select {
Expand Down Expand Up @@ -380,8 +380,8 @@ pub fn or_having(query qry: Select, having whr: Where) -> Select {
/// See function `having` on details why this takes a `Where`.
///
/// NOTICE: This operator does not exist in Postgres or Sqlite,
/// and *Cake* generates equivalent SQL using `OR` and `AND` and `NOT`.
/// This operator exists in MariaDB/MySQL.
/// and *Cake* generates equivalent SQL using `OR` and `AND` and `NOT`.
/// This operator exists in MariaDB/MySQL.
///
pub fn xor_having(query qry: Select, having whr: Where) -> Select {
case qry.having {
Expand Down
8 changes: 4 additions & 4 deletions src/cake/query/update.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ pub fn or_where(query qry: Update(a), where whr: Where) -> Update(a) {
/// current outermost `Where` are wrapped in an `XorWhere`.
///
/// NOTICE: This operator does not exist in Postgres or Sqlite,
/// and *Cake* generates equivalent SQL using `OR` and `AND` and `NOT`.
/// This operator exists in MariaDB/MySQL.
/// and *Cake* generates equivalent SQL using `OR` and `AND` and `NOT`.
/// This operator exists in MariaDB/MySQL.
///
pub fn xor_where(query qry: Update(a), where whr: Where) -> Update(a) {
case qry.where {
Expand Down Expand Up @@ -279,7 +279,7 @@ pub fn get_where(query qry: Update(a)) -> Where {
// ▒▒▒ RETURNING ▒▒▒

/// NOTICE: MariaDB/MySQL do not support `RETURNING` in `UPDATE` queries;
/// they do support it in `INSERT` (and `REPLACE`) queries, however.
/// they do support it in `INSERT` (and `REPLACE`) queries, however.
///
pub fn returning(
query qry: Update(a),
Expand All @@ -292,7 +292,7 @@ pub fn returning(
}

/// NOTICE: MariaDB/MySQL do not support `RETURNING` in `UPDATE` queries;
/// they do support it in `INSERT` (and `REPLACE`) queries, however.
/// they do support it in `INSERT` (and `REPLACE`) queries, however.
///
pub fn no_returning(query qry: Update(a)) -> Update(a) {
Update(..qry, returning: NoReturning)
Expand Down

0 comments on commit b42c740

Please sign in to comment.