mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
feat(db): keep SQLite's write and search semantics on Postgres
- UnitOfWork transactions take one advisory lock for the database on Postgres (DatabaseEngine.serializeWrites, pg_advisory_xact_lock), so a MAX(...) + 1 read inside one cannot race another, as with SQLite's single writer. SQLite needs nothing. - ilike(platform, refs) builds the case-insensitive search condition: LIKE on SQLite, ILIKE on Postgres, where LIKE is exact. The place searches use it. - Plugin data erasure runs each statement in its own savepoint: on Postgres a failed statement would abort the user's whole erasure transaction.
This commit is contained in:
@@ -44,6 +44,7 @@ import {
|
||||
dateOf,
|
||||
dayDistance,
|
||||
foundAgainState,
|
||||
ilike,
|
||||
lower,
|
||||
lowerParam,
|
||||
lowerTrim,
|
||||
@@ -269,6 +270,18 @@ export const HELPER_CASES: readonly HelperCase[] = [
|
||||
raw: (p) => rawOf(dayDistance(p, 'a', '2026-09-24')),
|
||||
expect: { equals: 3 },
|
||||
},
|
||||
{
|
||||
name: 'ilike matches in other case',
|
||||
row: { a: 'Probe Place' },
|
||||
raw: (p) => ({ sql: ilike(p, ['a']), params: ['%PLACE%'] }),
|
||||
expect: { equals: true },
|
||||
},
|
||||
{
|
||||
name: 'ilike keeps the escaped wildcard literal',
|
||||
row: { a: 'Probe Place' },
|
||||
raw: (p) => ({ sql: ilike(p, ['a']), params: ['probe\\_place'] }),
|
||||
expect: { equals: false },
|
||||
},
|
||||
{
|
||||
name: 'collateNoCase',
|
||||
row: { a: 'Probe' },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"scripts/db-call-graph.mjs": 1036,
|
||||
"scripts/generate-entities.ts": 2259,
|
||||
"src/db/repositories/Places.repository.ts": 1437,
|
||||
"src/db/repositories/Places.repository.ts": 1435,
|
||||
"src/db/repositories/Reservations.repository.ts": 1563,
|
||||
"src/db/repositories/Trips.repository.ts": 1121,
|
||||
"src/db/repositories/Users.repository.ts": 1445,
|
||||
|
||||
Reference in New Issue
Block a user