mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +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')
|
||||
|
||||
Reference in New Issue
Block a user