mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
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:
@@ -2,6 +2,7 @@ import {
|
||||
castIntegerKysely,
|
||||
concatKysely,
|
||||
currentTimestampKysely,
|
||||
integerTextEqualsKysely,
|
||||
nowPlusSecondsKysely,
|
||||
startsWithIsoDateKysely,
|
||||
substringKysely,
|
||||
@@ -230,6 +231,22 @@ describe('kysely-functions (postgres)', () => {
|
||||
expect(compiled.parameters).toEqual([]);
|
||||
});
|
||||
|
||||
it("SQLFPG-026: integerTextEqualsKysely compares the truncated text with the integer, so '14.0' meets 14", () => {
|
||||
const compiled = db
|
||||
.selectFrom('users')
|
||||
.select('id')
|
||||
.where((eb) => integerTextEqualsKysely(pg, eb, 'display_name', 'id'))
|
||||
.compile();
|
||||
expect(compiled.sql).toBe(
|
||||
'select "id" from "users" where cast(trunc(cast("display_name" as numeric)) as integer) = "id"',
|
||||
);
|
||||
expect(compiled.parameters).toEqual([]);
|
||||
class FakePlatform extends Platform {}
|
||||
expect(() =>
|
||||
integerTextEqualsKysely(new FakePlatform(), expressionBuilder<ProbeDB, 'users'>(), 'username', 'id'),
|
||||
).toThrow(/no implementation for platform FakePlatform/);
|
||||
});
|
||||
|
||||
it('SQLFPG-023: unixEpochToIsoKysely renders UTC ISO text from epoch milliseconds', () => {
|
||||
const compiled = db
|
||||
.selectFrom('users')
|
||||
|
||||
@@ -234,7 +234,7 @@ describe('reservation-visibility parity (RV2: publicStayExists vs publicStaySql)
|
||||
.selectFrom('day_accommodations as a')
|
||||
.select('a.id')
|
||||
.where('a.trip_id', '=', trip.id)
|
||||
.where((eb) => publicStayExists(eb))
|
||||
.where((eb) => publicStayExists(t.em.getPlatform(), eb))
|
||||
.orderBy('a.id', 'asc')
|
||||
.execute();
|
||||
const legacy = testDb
|
||||
@@ -260,7 +260,7 @@ describe('reservation-visibility parity (RV2: publicStayExists vs publicStaySql)
|
||||
.selectFrom('day_accommodations as a')
|
||||
.select('a.id')
|
||||
.where('a.trip_id', '=', trip.id)
|
||||
.where((eb) => publicStayExists(eb))
|
||||
.where((eb) => publicStayExists(t.em.getPlatform(), eb))
|
||||
.execute();
|
||||
const legacy = testDb
|
||||
// test-sql-allow: the legacy string fragment is this parity harness's oracle and has to run as written.
|
||||
@@ -290,7 +290,7 @@ describe('reservation-visibility parity (RV2: publicStayExists vs publicStaySql)
|
||||
.selectFrom('day_accommodations as a')
|
||||
.select('a.id')
|
||||
.where('a.trip_id', '=', trip.id)
|
||||
.where((eb) => publicStayExists(eb))
|
||||
.where((eb) => publicStayExists(t.em.getPlatform(), eb))
|
||||
.execute();
|
||||
const legacy = testDb
|
||||
// test-sql-allow: the legacy string fragment is this parity harness's oracle and has to run as written.
|
||||
@@ -322,7 +322,7 @@ describe('reservation-visibility parity (RV2: publicStayExists vs publicStaySql)
|
||||
.selectFrom('day_accommodations as a')
|
||||
.select('a.id')
|
||||
.where('a.trip_id', '=', trip.id)
|
||||
.where((eb) => publicStayExists(eb))
|
||||
.where((eb) => publicStayExists(t.em.getPlatform(), eb))
|
||||
.execute();
|
||||
const legacy = testDb
|
||||
// test-sql-allow: the legacy string fragment is this parity harness's oracle and has to run as written.
|
||||
@@ -351,7 +351,7 @@ describe('reservation-visibility parity (RV2: publicStayExists vs publicStaySql)
|
||||
.selectFrom('day_accommodations as a')
|
||||
.select('a.id')
|
||||
.where('a.trip_id', '=', trip.id)
|
||||
.where((eb) => publicStayExists(eb))
|
||||
.where((eb) => publicStayExists(t.em.getPlatform(), eb))
|
||||
.execute();
|
||||
const legacy = testDb
|
||||
// test-sql-allow: the legacy string fragment is this parity harness's oracle and has to run as written.
|
||||
@@ -386,7 +386,7 @@ describe('reservation-visibility parity (RV2: publicStayExists vs publicStaySql)
|
||||
.selectFrom('day_accommodations as a')
|
||||
.select('a.id')
|
||||
.where('a.trip_id', '=', trip.id)
|
||||
.where((eb) => publicStayExists(eb))
|
||||
.where((eb) => publicStayExists(t.em.getPlatform(), eb))
|
||||
.orderBy('a.id', 'asc')
|
||||
.execute();
|
||||
const legacy = testDb
|
||||
@@ -427,7 +427,7 @@ describe('reservation-visibility parity (RV2: publicStayExists vs publicStaySql)
|
||||
.selectFrom('day_accommodations as a')
|
||||
.select('a.id')
|
||||
.where('a.trip_id', '=', trip.id)
|
||||
.where((eb) => publicStayExists(eb))
|
||||
.where((eb) => publicStayExists(t.em.getPlatform(), eb))
|
||||
.execute();
|
||||
const legacy = testDb
|
||||
// test-sql-allow: the legacy string fragment is this parity harness's oracle and has to run as written.
|
||||
@@ -458,7 +458,7 @@ describe('reservation-visibility parity (RV2: publicStayExists vs publicStaySql)
|
||||
.selectFrom('day_accommodations as a')
|
||||
.select('a.id')
|
||||
.where('a.trip_id', '=', trip.id)
|
||||
.where((eb) => publicStayExists(eb))
|
||||
.where((eb) => publicStayExists(t.em.getPlatform(), eb))
|
||||
.execute();
|
||||
const legacy = testDb
|
||||
// test-sql-allow: the legacy string fragment is this parity harness's oracle and has to run as written.
|
||||
|
||||
Reference in New Issue
Block a user