Skip to content

Commit

Permalink
deps
Browse files Browse the repository at this point in the history
  • Loading branch information
inoas committed May 27, 2024
1 parent 1fa9796 commit bf056ff
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 41 deletions.
4 changes: 2 additions & 2 deletions birdie_snapshots/base_select_query.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ file: ./test/old_query_test.gleam
test_name: query_combined_snap_test
---
SelectQuery(
FromTable("cats"),
[
SelectColumn("name"),
SelectColumn("age"),
],
FromTable("cats"),
[],
NoWherePart,
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
)
4 changes: 2 additions & 2 deletions birdie_snapshots/cats_query.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ file: ./test/old_query_test.gleam
test_name: query_fragment_snap_test
---
SelectQuery(
FromTable("cats"),
[],
FromTable("cats"),
[],
NoWherePart,
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
)
4 changes: 2 additions & 2 deletions birdie_snapshots/cats_query_2.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ file: ./test/old_query_test.gleam
test_name: query_fragment_snap_test
---
SelectQuery(
FromTable("cats"),
[],
FromTable("cats"),
[],
WhereEqual(
WhereColumn("name"),
Expand All @@ -18,7 +18,7 @@ SelectQuery(
],
)),
),
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
)
4 changes: 2 additions & 2 deletions birdie_snapshots/cats_sub_query.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ file: ./test/old_query_test.gleam
test_name: query_select_snap_test
---
SelectQuery(
FromTable("cats"),
[],
FromTable("cats"),
[],
NoWherePart,
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
)
8 changes: 4 additions & 4 deletions birdie_snapshots/combined_query.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Combined(CombinedQuery(
UnionAll,
[
SelectQuery(
FromTable("cats"),
[
SelectColumn("name"),
SelectColumn("age"),
],
FromTable("cats"),
[],
OrWhere([
WhereLowerOrEqual(
Expand All @@ -24,23 +24,23 @@ Combined(CombinedQuery(
"%ara%",
),
]),
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
),
SelectQuery(
FromTable("cats"),
[
SelectColumn("name"),
SelectColumn("age"),
],
FromTable("cats"),
[],
NotWhere(WhereIsNotBool(
WhereColumn("is_wild"),
False,
)),
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
),
],
Expand Down
26 changes: 13 additions & 13 deletions birdie_snapshots/composed.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ file: ./test/old_query_test.gleam
test_name: query_select_snap_test
---
SelectQuery(
[
SelectColumn("cats.name"),
SelectColumn("cats.age"),
SelectAlias(
SelectColumn("owners.name"),
"owner_name",
),
],
FromSubQuery(
Select(SelectQuery(
FromTable("cats"),
[],
FromTable("cats"),
[],
NoWherePart,
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
)),
"cats",
),
[
SelectColumn("cats.name"),
SelectColumn("cats.age"),
SelectAlias(
SelectColumn("owners.name"),
"owner_name",
),
],
[
InnerJoin(
JoinTable("owners"),
Expand All @@ -43,12 +43,12 @@ SelectQuery(
),
CrossJoin(
JoinSubQuery(Select(SelectQuery(
FromTable("dogs"),
[],
FromTable("dogs"),
[],
NoWherePart,
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
))),
"dogs",
Expand All @@ -75,7 +75,7 @@ SelectQuery(
],
),
]),
LimitOffset(1, 0),
[OrderByColumnPart("cats.age", Asc)],
LimitOffset(1, 0),
NoEpilogPart,
)
4 changes: 2 additions & 2 deletions birdie_snapshots/dogs_sub_query.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ file: ./test/old_query_test.gleam
test_name: query_select_snap_test
---
SelectQuery(
FromTable("dogs"),
[],
FromTable("dogs"),
[],
NoWherePart,
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
)
4 changes: 2 additions & 2 deletions birdie_snapshots/query_where_between_builder_test.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ file: ./test/query_test.gleam
test_name: query_where_between_builder_test
---
SelectQuery(
FromTable("cats"),
[],
FromTable("cats"),
[],
WhereBetween(
WhereColumn("age"),
WhereParam(IntParam(10)),
WhereParam(IntParam(20)),
),
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
)
4 changes: 2 additions & 2 deletions birdie_snapshots/select_query_a.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ file: ./test/old_query_test.gleam
test_name: query_combined_snap_test
---
SelectQuery(
FromTable("cats"),
[
SelectColumn("name"),
SelectColumn("age"),
],
FromTable("cats"),
[],
OrWhere([
WhereLowerOrEqual(
Expand All @@ -21,7 +21,7 @@ SelectQuery(
"%ara%",
),
]),
NoLimitNoOffset,
[],
NoLimitNoOffset,
NoEpilogPart,
)
4 changes: 2 additions & 2 deletions birdie_snapshots/select_query_b.accepted
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ file: ./test/old_query_test.gleam
test_name: query_combined_snap_test
---
SelectQuery(
FromTable("cats"),
[
SelectColumn("name"),
SelectColumn("age"),
],
FromTable("cats"),
[],
NotWhere(WhereIsNotBool(
WhereColumn("is_wild"),
False,
)),
NoLimitNoOffset,
[
OrderByColumnPart(
"will_be_removed",
Asc,
),
],
NoLimitNoOffset,
NoEpilogPart,
)
1 change: 1 addition & 0 deletions gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ description = "An SQL query builder for Gleam targeting Postgres and SQLite - a
licences = ["AGPL-3.0-or-later"]
repository = { type = "github", user = "inoas", repo = "gleam-cake" }
# links = [{ title = "Website", href = "https://gleam.run" }]
gleam = ">= 1.2.0 and < 2.0.0"

[dependencies]
# act
Expand Down
17 changes: 9 additions & 8 deletions src/cake/internal/query.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ pub fn order_by_part_to_sql(order_by_part ordbpt: OrderByPart) -> String {
// │ Limit & Offset Part │
// └───────────────────────────────────────────────────────────────────────────┘

// TODO: split limit and offset into separate types and separate functions
// then add one combination function to set both limit and offset.
pub type LimitOffsetPart {
LimitOffset(limit: Int, offset: Int)
LimitNoOffset(limit: Int)
Expand Down Expand Up @@ -347,23 +349,22 @@ pub fn combined_order_by(
// List of SQL parts that will be used to build a select query.
pub type SelectQuery {
SelectQuery(
from: FromPart,
// comment: String,
// modifier: String,
// with: String,
// with_recursive: String, ?
select: List(SelectValue),
// modifier: String,
// distinct: String,
// window: String,
from: FromPart,
join: List(JoinPart),
where: WherePart,
// group_by: String,
// having: String,
// window: String,
// values: String, ?
// with_recursive: String, ?
limit_offset: LimitOffsetPart,
order_by: List(OrderByPart),
// kind: SelectQueryKind,
limit_offset: LimitOffsetPart,
epilog: EpilogPart,
// comment: String,
// values: String, ?
)
}

Expand Down

0 comments on commit bf056ff

Please sign in to comment.