Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/db/package.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has this leaked in from another branch, or due to where you branched off?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't compile for me. I assumed it is due to renovate having upgraded something and now requiring this package explicitly.

Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"typescript": ">=4.7"
},
"devDependencies": {
"@tanstack/config": "^0.22.2",
"@vitest/coverage-istanbul": "^3.2.4",
"arktype": "^2.1.28",
"mitt": "^3.0.1",
Expand Down
30 changes: 30 additions & 0 deletions packages/db/tests/query/compiler/evaluators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,36 @@ describe(`evaluators`, () => {
}
})

it(`handles eq with Date objects (should compare by getTime(), not reference)`, () => {
// Create two Date objects with the same time value
// They are different object instances but represent the same moment
const date1 = new Date(`2024-01-15T10:30:45.123Z`)
const date2 = new Date(`2024-01-15T10:30:45.123Z`)

// Verify they are different object references
expect(date1).not.toBe(date2)
// But they have the same time value
expect(date1.getTime()).toBe(date2.getTime())

const func = new Func(`eq`, [new Value(date1), new Value(date2)])
const compiled = compileExpression(func)

// Should return true because they represent the same time
// Currently this fails because eq() does referential comparison
expect(compiled({})).toBe(true)
})

it(`handles eq with Date objects with different times`, () => {
const date1 = new Date(`2024-01-15T10:30:45.123Z`)
const date2 = new Date(`2024-01-15T10:30:45.124Z`) // 1ms later

const func = new Func(`eq`, [new Value(date1), new Value(date2)])
const compiled = compileExpression(func)

// Should return false because they represent different times
expect(compiled({})).toBe(false)
})

it(`handles eq with Uint8Arrays created with length (repro case)`, () => {
// Reproduction of user's issue: new Uint8Array(5) creates [0,0,0,0,0]
const array1 = new Uint8Array(5) // Creates array of length 5, all zeros
Expand Down
Loading
Loading