Skip to content

Commit 9c82f50

Browse files
committed
fix(stack): compare bigint order domains in v3 drizzle operators oracle
The bigint_ord/bigint_ord_ore domains are ORE-indexed, so their i64 bigint samples flow into comparePlain, which only handled Date/number/ string and threw "Unsupported ordered values" at runtime. Add a bigint branch (mirroring matrix-live-pg's oracle) and widen PlainValue.
1 parent 1be5b5e commit 9c82f50

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/stack/__tests__/drizzle-v3/operators-live-pg.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const BIGINT_LEDGER = -9223372036854775808n
8686
const schema = extractEncryptionSchemaV3(matrixTable)
8787
const bigintSchema = extractEncryptionSchemaV3(bigintTable)
8888

89-
type PlainValue = string | number | boolean | Date
89+
type PlainValue = string | number | bigint | boolean | Date
9090
type RowKey = typeof ROW_A | typeof ROW_B
9191
type MatrixPlainRow = Record<string, PlainValue | null | string>
9292
type SelectRow = { rowKey: string }
@@ -139,6 +139,12 @@ function comparePlain(left: PlainValue, right: PlainValue): number {
139139
if (typeof left === 'number' && typeof right === 'number') {
140140
return left - right
141141
}
142+
// bigint order domains (`bigint_ord`/`bigint_ord_ore`) carry i64 samples
143+
// beyond Number.MAX_SAFE_INTEGER, so they must be compared as bigints — the
144+
// subtraction is narrowed to -1/0/1 because callers expect a `number`.
145+
if (typeof left === 'bigint' && typeof right === 'bigint') {
146+
return left < right ? -1 : left > right ? 1 : 0
147+
}
142148
if (typeof left === 'string' && typeof right === 'string') {
143149
// eql_v3 text ordering (ORE) is BYTEWISE, not locale-collated: the oracle
144150
// must model codepoint order, not `localeCompare` (which folds case,

0 commit comments

Comments
 (0)