fix(db): match a stay-linked booking on Postgres in the public stay check

publicStayExists cast reservations.accommodation_id straight to integer,
which Postgres refuses for the stored '14.0', so the calendar feed and the
share links failed for every trip once any booking was linked to a stay.
The correlation now goes through accommodationIdMatches, which compares
through the new dialect helper integerTextEqualsKysely, and the Wallet pass
context uses the same helper instead of its own numeric cast.
This commit is contained in:
Maurice
2026-11-17 11:40:14 +01:00
parent 518287ff12
commit 4a3ad562a7
8 changed files with 90 additions and 24 deletions
+21
View File
@@ -19,6 +19,7 @@ import {
castIntegerKysely,
concatKysely,
currentTimestampKysely,
integerTextEqualsKysely,
nowPlusSecondsKysely,
startsWithIsoDateKysely,
substringKysely,
@@ -355,6 +356,26 @@ export const HELPER_CASES: readonly HelperCase[] = [
kysely: (p, eb) => castIntegerKysely(p, eb, 'a'),
expect: { equals: 14 },
},
...['14', '14.0'].map(
(stored): HelperCase => ({
name: `integerTextEqualsKysely matches the text ${stored} to 14`,
row: { a: stored, n: 14 },
kysely: (p, eb) => eb.case().when(integerTextEqualsKysely(p, eb, 'a', 'n')).then('yes').else('no').end(),
expect: { equals: 'yes' },
}),
),
{
name: 'integerTextEqualsKysely matches the number 14 to 14',
row: { n: 14 },
kysely: (p, eb) => eb.case().when(integerTextEqualsKysely(p, eb, 'n', 'n')).then('yes').else('no').end(),
expect: { equals: 'yes' },
},
{
name: 'integerTextEqualsKysely tells 15.0 from 14',
row: { a: '15.0', n: 14 },
kysely: (p, eb) => eb.case().when(integerTextEqualsKysely(p, eb, 'a', 'n')).then('yes').else('no').end(),
expect: { equals: 'no' },
},
{
name: 'unixEpochToIsoKysely',
row: { n: EPOCH_MS },