The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(db): match a stay's bookings by the stored '<id>.0' text, as SQLite did
Maurice0e911608afcf
diff --git a/server/src/db/repositories/Reservations.repository.ts b/server/src/db/repositories/Reservations.repository.tsindex d2c1f7929..53cd7d6a2 100644--- a/server/src/db/repositories/Reservations.repository.ts+++ b/server/src/db/repositories/Reservations.repository.ts@@ -609,7 +609,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {.else(concatKysely(platform, eb, { value: date }, { expression: substringKysely(platform, eb, 'reservation_time', 11) })).end(),}))- .where((eb) => reservationStayIs(this.getEntityManager().getPlatform(), eb, 'accommodation_id', accommodation_id))+ .where((eb) => reservationStayIs(eb, 'accommodation_id', accommodation_id)).where('type', '=', 'hotel').execute();}@@ -715,7 +715,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {const rows = await this.kysely<ReservationsByAccommodationKyselyDB>().selectFrom('reservations').select(['id', 'metadata'])- .where((eb) => reservationStayIs(this.getEntityManager().getPlatform(), eb, 'accommodation_id', accommodation_id))+ .where((eb) => reservationStayIs(eb, 'accommodation_id', accommodation_id)).execute();return rows as { id: number; metadata: string | null }[];}@@ -759,7 +759,7 @@ export class ReservationsRepository extends TrekRepository<Reservations> {const rows = await this.kysely<ReservationsByAccommodationKyselyDB>().selectFrom('reservations').select(['id'])- .where((eb) => reservationStayIs(this.getEntityManager().getPlatform(), eb, 'accommodation_id', accommodation_id))+ .where((eb) => reservationStayIs(eb, 'accommodation_id', accommodation_id)).execute();return rows as { id: number }[];}diff --git a/server/src/db/repositories/_shared/reservation-accommodation.ts b/server/src/db/repositories/_shared/reservation-accommodation.tsindex 5dab7733c..1b46a7c6e 100644--- a/server/src/db/repositories/_shared/reservation-accommodation.ts+++ b/server/src/db/repositories/_shared/reservation-accommodation.ts@@ -1,4 +1,5 @@-import { castIntegerKysely, integerTextEqualsKysely } from '../../dialect/kysely-functions';+import { legacyBoundIntegerText } from '../../../nest/common/row-id';+import { integerTextEqualsKysely } from '../../dialect/kysely-functions';import type { Platform } from '@mikro-orm/core';import type { ExpressionBuilder, ExpressionWrapper, SqlBool, StringReference } from 'kysely';@@ -24,16 +25,17 @@ export function accommodationIdMatches<DB, TB extends keyof DB>(/*** A reservation booked against the stay `stayId`, the filter form of- * {@link accommodationIdMatches}: the TEXT column read as an integer, so the- * stored `'14.0'` matches 14 on Postgres too. Compared as written (`= 14`),- * Postgres binds the number as the text `'14'` and finds no row at all, which- * no error reports.+ * {@link accommodationIdMatches}, held to the legacy compare: SQLite bound the+ * id as a REAL, so only the stored `'<id>.0'` shape ever matched, never `'14'`,+ * `' 14'` or `'14abc'` (Reservations.repository.test.ts AC37/AC40). Comparing+ * the column with that same text keeps that on both engines. Compared with a+ * bare number instead, Postgres binds it as the text `'14'` and finds no row+ * at all, which no error reports.*/export function reservationStayIs<DB, TB extends keyof DB>(- platform: Platform,eb: ExpressionBuilder<DB, TB>,accommodationId: StringReference<DB, TB>,stayId: number,): ExpressionWrapper<DB, TB, SqlBool> {- return eb(castIntegerKysely(platform, eb, accommodationId), '=', stayId);+ return eb(accommodationId, '=', legacyBoundIntegerText(stayId));}