Skip to content

Commit

Permalink
added mysql first class support
Browse files Browse the repository at this point in the history
  • Loading branch information
inoas committed Jun 28, 2024
1 parent cf4a08f commit f28ab2a
Show file tree
Hide file tree
Showing 51 changed files with 512 additions and 58 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.6.0 - 2024-06-27

- Added MySQL independent of MariaDB as first class supported.

## 0.5.0 - 2024-06-26

- Fixed github CI and docker compose testing against Postgres and MariaDB.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ title: combined_except_execution_result_test
file: ./test/cake_test/combined_test.gleam
test_name: combined_except_execution_result_test
---
#(Ok([]), Ok([]), Ok([]))
#(Ok([]), Ok([]), Ok([]), Ok([]))
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: combined_except_prepared_statement_test
0,
Maria,
),
PreparedStatement(
"?",
"(SELECT * FROM cats ORDER BY name ASC LIMIT 10) EXCEPT (SELECT * FROM cats ORDER BY name ASC LIMIT 10) ORDER BY age ASC LIMIT 1 OFFSET 2",
[],
0,
Mysql,
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ test_name: combined_intersect_execution_result_test
#(
Ok([#("Ginny", 6, False, 3, Null)]),
Ok([#("Ginny", 6, 0, 3, Undefined)]),
Ok([#("Ginny", 6, 0, 3, Undefined)]),
Ok([["Ginny", 6, 0, 3, Null]]),
Ok([["Ginny", 6, 0, 3, Null]]),
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: combined_intersect_prepared_statement_test
0,
Maria,
),
PreparedStatement(
"?",
"(SELECT * FROM cats ORDER BY name ASC LIMIT 10) INTERSECT (SELECT * FROM cats ORDER BY name ASC LIMIT 10) ORDER BY age ASC LIMIT 1 OFFSET 2",
[],
0,
Mysql,
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ test_name: combined_limit_offset_execution_result_test
Ok([#("Clara", 3, True, Null, 10.0)]),
Ok([#("Clara", 3, 1, Undefined, 10.0)]),
Ok([["Clara", 3, 1, Null, 10.0]]),
Ok([["Clara", 3, 1, Null, 10.0]]),
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: combined_limit_offset_prepared_statement_test
0,
Maria,
),
PreparedStatement(
"?",
"(SELECT * FROM cats ORDER BY name ASC LIMIT 4) UNION ALL (SELECT * FROM cats ORDER BY name ASC LIMIT 4) ORDER BY name ASC LIMIT 1 OFFSET 2",
[],
0,
Mysql,
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ test_name: combined_union_all_execution_result_test
]),
Ok([#("Nubi", 4, 1, 1, 2.2)]),
Ok([["Nubi", 4, 1, 1, 2.2]]),
Ok([["Nubi", 4, 1, 1, 2.2]]),
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: combined_union_all_prepared_statement_test
0,
Maria,
),
PreparedStatement(
"?",
"(SELECT * FROM cats ORDER BY name ASC LIMIT 10) UNION ALL (SELECT * FROM cats ORDER BY name ASC LIMIT 10) ORDER BY age ASC LIMIT 1 OFFSET 2",
[],
0,
Mysql,
),
)
1 change: 1 addition & 0 deletions birdie_snapshots/fragment_execution_result_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ test_name: fragment_execution_result_test
Ok([#("Clara", 3, True, Null, 10.0)]),
Ok([#("Clara", 3, 1, Undefined, 10.0)]),
Ok([["Clara", 3, 1, Null, 10.0]]),
Ok([["Clara", 3, 1, Null, 10.0]]),
)
7 changes: 7 additions & 0 deletions birdie_snapshots/fragment_prepared_statement_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: fragment_prepared_statement_test
1,
Maria,
),
PreparedStatement(
"?",
"SELECT * FROM cats WHERE LOWER(cats.name) = LOWER(?)",
[StringParam("Clara")],
1,
Mysql,
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ test_name: insert_records_execution_result_test
Ok([#("Whiskers"), #("Mittens")]),
Ok([#("Whiskers"), #("Mittens")]),
Ok([]),
Ok([]),
)
14 changes: 14 additions & 0 deletions birdie_snapshots/insert_records_prepared_statement_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,18 @@ test_name: insert_records_prepared_statement_test
6,
Maria,
),
PreparedStatement(
"?",
"INSERT INTO cats (name, rating, age) VALUES (?, ?, ?), (?, ?, ?)",
[
StringParam("Whiskers"),
FloatParam(5.0),
IntParam(3),
StringParam("Mittens"),
FloatParam(4.5),
IntParam(5),
],
6,
Mysql,
),
)
20 changes: 20 additions & 0 deletions birdie_snapshots/insert_records_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,24 @@ test_name: insert_records_test
NoEpilog,
NoComment,
)),
InsertQuery(Insert(
InsertIntoTable("cats"),
InsertColumns([
"name",
"rating",
"age",
]),
NoInsertModifier,
InsertSourceRecords(
[
Cat("Whiskers", 3, False, 5.0),
Cat("Mittens", 5, True, 4.5),
],
//fn(a) { ... },
),
InsertConflictError,
NoReturning,
NoEpilog,
NoComment,
)),
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ test_name: insert_values_execution_result_test
Ok([#("Whiskers")]),
Ok([#("Whiskers")]),
Ok([]),
Ok([]),
)
11 changes: 11 additions & 0 deletions birdie_snapshots/insert_values_prepared_statement_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,15 @@ test_name: insert_values_prepared_statement_test
3,
Maria,
),
PreparedStatement(
"?",
"INSERT INTO cats (name, rating, age) VALUES (?, ?, ?)",
[
StringParam("Whiskers"),
FloatParam(5.0),
IntParam(5),
],
3,
Mysql,
),
)
26 changes: 26 additions & 0 deletions birdie_snapshots/insert_values_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,30 @@ test_name: insert_values_test
NoEpilog,
NoComment,
)),
InsertQuery(Insert(
InsertIntoTable("cats"),
InsertColumns([
"name",
"rating",
"age",
]),
NoInsertModifier,
InsertSourceRows([
InsertRow([
InsertParam(
"name",
StringParam("Whiskers"),
),
InsertParam(
"rating",
FloatParam(5.0),
),
InsertParam("age", IntParam(5)),
]),
]),
InsertConflictError,
NoReturning,
NoEpilog,
NoComment,
)),
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ test_name: select_distinct_execution_result_test
Ok([False, True, Null]),
Ok([Undefined, #(0), #(1)]),
Ok([[Null], [0], [1]]),
Ok([[Null], [0], [1]]),
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: select_distinct_prepared_statement_test
0,
Maria,
),
PreparedStatement(
"?",
"SELECT DISTINCT is_wild FROM cats ORDER BY is_wild ASC",
[],
0,
Mysql,
),
)
7 changes: 7 additions & 0 deletions birdie_snapshots/select_execution_result_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: select_execution_result_test
["Karl", "hello", 8, 8],
["Clara", "hello", 3, 3],
]),
Ok([
["Nubi", "hello", 4, 4],
["Biffy", "hello", 10, 10],
["Ginny", "hello", 6, 6],
["Karl", "hello", 8, 8],
["Clara", "hello", 3, 3],
]),
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ test_name: select_limit_offset_execution_result_test
["Ginny", 6, 0, 3, Null],
["Karl", 8, 1, Null, 10.0],
]),
Ok([
["Biffy", 10, Null, 2, 1.1],
["Clara", 3, 1, Null, 10.0],
["Ginny", 6, 0, 3, Null],
["Karl", 8, 1, Null, 10.0],
]),
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: select_limit_offset_prepared_statement_test
0,
Maria,
),
PreparedStatement(
"?",
"SELECT * FROM cats ORDER BY name ASC LIMIT 4",
[],
0,
Mysql,
),
)
7 changes: 7 additions & 0 deletions birdie_snapshots/select_prepared_statement_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: select_prepared_statement_test
1,
Maria,
),
PreparedStatement(
"?",
"SELECT name, ?, age, age AS years_since_birth FROM cats",
[StringParam("hello")],
1,
Mysql,
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ test_name: select_query_execution_result_test
Ok([#("Ginny"), #("Nubi")]),
Ok([#("Ginny"), #("Nubi")]),
Ok([["Ginny"], ["Nubi"]]),
Ok([["Ginny"], ["Nubi"]]),
)
10 changes: 10 additions & 0 deletions birdie_snapshots/select_query_prepared_statement_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ test_name: select_query_prepared_statement_test
2,
Maria,
),
PreparedStatement(
"?",
"SELECT cats.name FROM cats CROSS JOIN owners AS owners WHERE owners.name LIKE ? GROUP BY cats.name HAVING cats.name LIKE ? ORDER BY cats.name ASC LIMIT 10 OFFSET 1 /* an epilog such as FOR UPDATE could be here */ -- my regular comment /* */",
[
StringParam("%i%"),
StringParam("%i%"),
],
2,
Mysql,
),
)
1 change: 1 addition & 0 deletions birdie_snapshots/update_execution_result_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ test_name: update_execution_result_test
#("Clara the elder", 4),
]),
Ok([]),
Ok([]),
)
7 changes: 7 additions & 0 deletions birdie_snapshots/update_prepared_statement_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: update_prepared_statement_test
0,
Maria,
),
PreparedStatement(
"?",
"UPDATE cats SET age = age + 1, name = CONCAT(name, ' the elder')",
[],
0,
Mysql,
),
)
20 changes: 20 additions & 0 deletions birdie_snapshots/update_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,24 @@ test_name: update_test
NoEpilog,
NoComment,
)),
UpdateQuery(Update(
UpdateTable("cats"),
NoUpdateModifier,
UpdateSets([
UpdateExpressionSet(
["age"],
"age + 1",
),
UpdateExpressionSet(
["name"],
"CONCAT(name, ' the elder')",
),
]),
NoFrom,
NoJoins,
NoWhere,
NoReturning,
NoEpilog,
NoComment,
)),
)
5 changes: 5 additions & 0 deletions birdie_snapshots/where_any_execution_result_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ test_name: where_any_execution_result_test
["Biffy", 10, Null, 2, 1.1],
["Ginny", 6, 0, 3, Null],
]),
Ok([
["Nubi", 4, 1, 1, 2.2],
["Biffy", 10, Null, 2, 1.1],
["Ginny", 6, 0, 3, Null],
]),
)
7 changes: 7 additions & 0 deletions birdie_snapshots/where_any_prepared_statement_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ test_name: where_any_prepared_statement_test
0,
Maria,
),
PreparedStatement(
"?",
"SELECT * FROM cats WHERE owner_id = ANY(SELECT owner_id FROM dogs)",
[],
0,
Mysql,
),
)
4 changes: 4 additions & 0 deletions birdie_snapshots/where_execution_result_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ test_name: where_execution_result_test
["Karl", 8, 1, Null, 10.0],
["Clara", 3, 1, Null, 10.0],
]),
Ok([
["Karl", 8, 1, Null, 10.0],
["Clara", 3, 1, Null, 10.0],
]),
)
Loading

0 comments on commit f28ab2a

Please sign in to comment.