Skip to content

Commit

Permalink
chore(zql): integration test more complex conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
tantaman committed Jun 4, 2024
1 parent 1c40c67 commit 6ec3986
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# build outputs
**/*.tgz

# sqlite dbs
*.db

# turbo
.turbo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,45 @@ describe('complex expressions', async () => {
z.query.track.where(or(exp('id', '=', '001'), exp('id', '=', '002'))),
expected: tracks.slice(0, 2),
},
{
name: 'cursor style with 2 orderings',
query: () =>
z.query.track
.asc('title', 'albumId')
.where('title', 'IN', ['a', 'c'])
.where(
or(
exp('title', '>', 'a'),
and(exp('title', '=', 'a'), exp('albumId', '>', '001')),
and(
exp('title', '=', 'a'),
exp('albumId', '=', '001'),
exp('id', '>', '001'),
),
),
)
.limit(1),
expected: [tracks[1]],
},
{
name: 'cursor style with 2 orderings, less overlap',
query: () =>
z.query.track
.asc('title', 'length')
.where(
or(
exp('title', '>', 'a'),
and(exp('title', '=', 'a'), exp('length', '>', 100)),
and(
exp('title', '=', 'a'),
exp('length', '=', 100),
exp('id', '>', '001'),
),
),
)
.limit(1),
expected: [tracks[1]],
},
])('$name', async ({query, expected}) => {
const stmt = query().prepare();
const rows = await stmt.exec();
Expand Down

0 comments on commit 6ec3986

Please sign in to comment.