fix(db): match a booking to its stay on Postgres without failing on odd ids

The Postgres stay match now casts the leading digits of the stored text as bigint, the way SQLite reads it, so a non-numeric or oversized accommodation_id no longer fails the calendar, share and stay reads for every trip.
This commit is contained in:
Maurice
2026-11-23 14:56:17 +01:00
parent bf8677a28c
commit 3a2645a3e4
3 changed files with 35 additions and 10 deletions
+14
View File
@@ -370,6 +370,20 @@ export const HELPER_CASES: readonly HelperCase[] = [
kysely: (p, eb) => eb.case().when(integerTextEqualsKysely(p, eb, 'n', 'n')).then('yes').else('no').end(),
expect: { equals: 'yes' },
},
...['abc', '', '14abc'].map(
(stored): HelperCase => ({
name: `integerTextEqualsKysely reads the text ${JSON.stringify(stored)} by its leading digits without failing`,
row: { a: stored, n: 14 },
kysely: (p, eb) => eb.case().when(integerTextEqualsKysely(p, eb, 'a', 'n')).then('yes').else('no').end(),
expect: { equals: stored === '14abc' ? 'yes' : 'no' },
}),
),
{
name: 'integerTextEqualsKysely matches an id past 2^31',
row: { a: '3000000000.0', n: 3000000000 },
kysely: (p, eb) => eb.case().when(integerTextEqualsKysely(p, eb, 'a', 'n')).then('yes').else('no').end(),
expect: { equals: 'yes' },
},
{
name: 'integerTextEqualsKysely tells 15.0 from 14',
row: { a: '15.0', n: 14 },