Skip to content

Commit 7a077a8

Browse files
committed
checkpoint
1 parent 818cd7b commit 7a077a8

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

packages/db/tests/query/group-by.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,6 @@ function createGroupByTests(autoIndex: `off` | `eager`): void {
11001100
state: orders.customer?.address?.state,
11011101
order_count: count(orders.id),
11021102
total_amount: sum(orders.amount),
1103-
cities: orders.customer?.address?.city,
11041103
})),
11051104
})
11061105

@@ -1250,7 +1249,6 @@ function createGroupByTests(autoIndex: `off` | `eager`): void {
12501249
),
12511250
order_count: count(orders.id),
12521251
total_amount: sum(orders.amount),
1253-
has_tracking: isNotUndefined(orders.shipping?.tracking),
12541252
})),
12551253
})
12561254

packages/db/tests/query/order-by.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it } from "vitest"
22
import { createCollection } from "../../src/collection.js"
33
import { mockSyncCollectionOptions } from "../utls.js"
44
import { createLiveQueryCollection } from "../../src/query/live-query-collection.js"
5-
import { eq, gt } from "../../src/query/builder/functions.js"
5+
import { eq, gt, isNotUndefined } from "../../src/query/builder/functions.js"
66

77
type Person = {
88
id: string
@@ -1183,7 +1183,7 @@ function createOrderByTests(autoIndex: `off` | `eager`): void {
11831183
const collection = createLiveQueryCollection((q) =>
11841184
q
11851185
.from({ persons: personsCollection })
1186-
.where(({ persons }) => persons.address !== undefined)
1186+
.where(({ persons }) => isNotUndefined(persons.address))
11871187
.orderBy(({ persons }) => persons.address?.coordinates?.lat, `asc`)
11881188
.select(({ persons }) => ({
11891189
id: persons.id,
@@ -1233,9 +1233,9 @@ function createOrderByTests(autoIndex: `off` | `eager`): void {
12331233
const results = Array.from(collection.values())
12341234
expect(results).toHaveLength(4)
12351235

1236-
// Person without profile should have score 0 and be last
1237-
expect(results.map((r) => r.score)).toEqual([92, 85, 78, 0])
1238-
expect(results[3]!.name).toBe(`Test Person`)
1236+
// Person without profile should have undefined score and be first (undefined sorts first)
1237+
expect(results.map((r) => r.score)).toEqual([undefined, 92, 85, 78])
1238+
expect(results[0]!.name).toBe(`Test Person`)
12391239
})
12401240

12411241
it(`maintains ordering during live updates of nested properties`, async () => {
@@ -1302,17 +1302,17 @@ function createOrderByTests(autoIndex: `off` | `eager`): void {
13021302
const results = Array.from(collection.values())
13031303
expect(results).toHaveLength(3)
13041304

1305-
// Should be ordered: Los Angeles, New York, undefined (John Smith has no address)
1306-
// Note: undefined values in ORDER BY may be handled differently by the query engine
1305+
// Should be ordered: undefined, Los Angeles, New York (undefined sorts first)
1306+
// Note: undefined values in ORDER BY sort first in our implementation
13071307
expect(results.map((r) => r.city)).toEqual([
1308+
undefined,
13081309
`Los Angeles`,
13091310
`New York`,
1310-
undefined,
13111311
])
13121312
expect(results.map((r) => r.name)).toEqual([
1313+
`John Smith`,
13131314
`Jane Doe`,
13141315
`John Doe`,
1315-
`John Smith`,
13161316
])
13171317
})
13181318
})

packages/db/tests/query/where.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
gt,
1212
gte,
1313
inArray,
14+
isNotNull,
15+
isNotUndefined,
1416
length,
1517
like,
1618
lower,
@@ -1436,7 +1438,7 @@ function createWhereTests(autoIndex: `off` | `eager`): void {
14361438
.select(({ emp }) => ({
14371439
id: emp.id,
14381440
name: emp.name,
1439-
hasAddress: emp.contact?.address !== null,
1441+
hasAddress: isNotNull(emp.contact?.address),
14401442
})),
14411443
})
14421444

@@ -1451,7 +1453,7 @@ function createWhereTests(autoIndex: `off` | `eager`): void {
14511453
query: (q) =>
14521454
q
14531455
.from({ emp: employeesCollection })
1454-
.where(({ emp }) => emp.profile !== undefined)
1456+
.where(({ emp }) => isNotUndefined(emp.profile))
14551457
.select(({ emp }) => ({
14561458
id: emp.id,
14571459
name: emp.name,
@@ -1524,7 +1526,7 @@ function createWhereTests(autoIndex: `off` | `eager`): void {
15241526
query: (q) =>
15251527
q
15261528
.from({ emp: employeesCollection })
1527-
.where(({ emp }) => emp.contact?.emergency !== undefined)
1529+
.where(({ emp }) => isNotUndefined(emp.contact?.emergency))
15281530
.select(({ emp }) => ({
15291531
id: emp.id,
15301532
name: emp.name,
@@ -1613,7 +1615,7 @@ function createWhereTests(autoIndex: `off` | `eager`): void {
16131615
query: (q) =>
16141616
q
16151617
.from({ emp: employeesCollection })
1616-
.where(({ emp }) => emp.profile?.skills !== undefined)
1618+
.where(({ emp }) => isNotUndefined(emp.profile?.skills))
16171619
.select(({ emp }) => ({
16181620
id: emp.id,
16191621
name: emp.name,

0 commit comments

Comments
 (0)