-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
131 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
version: 1.1.6 | ||
title: where_execution_result_test | ||
file: ./test/cake/internal/query/where_test.gleam | ||
test_name: where_execution_result_test | ||
--- | ||
#(Ok([]), Ok([])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
version: 1.1.6 | ||
title: where_prepared_statement_test | ||
file: ./test/cake/internal/query/where_test.gleam | ||
test_name: where_prepared_statement_test | ||
--- | ||
#( | ||
PreparedStatement( | ||
"$", | ||
"SELECT * FROM cats WHERE $1 = name", | ||
[StringParam("Hello")], | ||
1, | ||
), | ||
PreparedStatement( | ||
"?", | ||
"SELECT * FROM cats WHERE ?1 = name", | ||
[StringParam("Hello")], | ||
1, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
version: 1.1.6 | ||
title: where_test | ||
file: ./test/cake/internal/query/where_test.gleam | ||
test_name: where_test | ||
--- | ||
#( | ||
SelectQuery(Select( | ||
NoSelects, | ||
FromTable("cats"), | ||
NoJoins, | ||
WhereEqual( | ||
WhereParam(StringParam("Hello")), | ||
WhereColumn("name"), | ||
), | ||
NoGroupBy, | ||
NoWhere, | ||
NoOrderBy, | ||
NoLimitNoOffset, | ||
NoEpilog, | ||
)), | ||
SelectQuery(Select( | ||
NoSelects, | ||
FromTable("cats"), | ||
NoJoins, | ||
WhereEqual( | ||
WhereParam(StringParam("Hello")), | ||
WhereColumn("name"), | ||
), | ||
NoGroupBy, | ||
NoWhere, | ||
NoOrderBy, | ||
NoLimitNoOffset, | ||
NoEpilog, | ||
)), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import birdie | ||
import cake/adapter/postgres_adapter | ||
import cake/adapter/sqlite_adapter | ||
import cake/query/fragment as frgmt | ||
import cake/query/from as f | ||
import cake/query/select as s | ||
import cake/query/where as w | ||
import pprint.{format as to_string} | ||
import test_helper/postgres_test_helper | ||
import test_helper/sqlite_test_helper | ||
|
||
fn where_query() { | ||
f.table(name: "cats") | ||
|> s.new_from | ||
|> s.where(w.col("age") |> w.eq(w.int(10))) | ||
|> s.where(w.fragment(frgmt.literal("1 = 1"))) | ||
|> s.where(w.string("Hello") |> w.eq(w.col("name"))) | ||
|> s.to_query | ||
} | ||
|
||
pub fn where_test() { | ||
let expected_pgo = where_query() | ||
let expected_sql = where_query() | ||
|
||
#(expected_pgo, expected_sql) | ||
|> to_string | ||
|> birdie.snap("where_test") | ||
} | ||
|
||
pub fn where_prepared_statement_test() { | ||
let expected_pgo = where_query() |> postgres_adapter.to_prepared_statement | ||
let expected_sql = where_query() |> sqlite_adapter.to_prepared_statement | ||
|
||
#(expected_pgo, expected_sql) | ||
|> to_string | ||
|> birdie.snap("where_prepared_statement_test") | ||
} | ||
|
||
pub fn where_execution_result_test() { | ||
let expected_pgo = where_query() |> postgres_test_helper.setup_and_run | ||
let expected_sql = where_query() |> sqlite_test_helper.setup_and_run | ||
|
||
where_query() | ||
#(expected_pgo, expected_sql) | ||
|> to_string | ||
|> birdie.snap("where_execution_result_test") | ||
} |