mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 05:26:47 +00:00
Merge dev into fix/prettier
Brings in the Tours addon and the MikroORM follow-ups. Conflicts were resolved to dev's content, then every file dev brought in was run through prettier and eslint --fix so the branch stays uniformly formatted.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
absDifference,
|
||||
caseWhenEquals,
|
||||
caseWhenNotNull,
|
||||
castInteger,
|
||||
castIntegerKysely,
|
||||
coalesce,
|
||||
@@ -704,6 +705,32 @@ describe('sql-functions (sqlite)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
// Tours (#2586): the assignment projection's `tour_route_geometry` column.
|
||||
it('SQLF-098: caseWhenNotNull yields the THEN column only where the test column is not null', async () => {
|
||||
const { user: a } = createUser(testDb);
|
||||
const { user: b } = createUser(testDb);
|
||||
testDb.prepare('UPDATE users SET display_name = ? WHERE id = ?').run('Shown', a.id);
|
||||
testDb.prepare('UPDATE users SET display_name = NULL WHERE id = ?').run(b.id);
|
||||
const platform = t.em.getPlatform();
|
||||
|
||||
const rows = await t.em
|
||||
.createQueryBuilder(Users, 'u')
|
||||
.select(['u.id', caseWhenNotNull(platform, 'u.display_name', 'u.username').as('picked')])
|
||||
.where({ id: { $in: [a.id, b.id] } })
|
||||
.orderBy({ id: 'asc' })
|
||||
.execute('all', false);
|
||||
expect(rows).toEqual([
|
||||
{ id: a.id, picked: a.username },
|
||||
{ id: b.id, picked: null },
|
||||
]);
|
||||
});
|
||||
|
||||
it('SQLF-099: an unknown platform fails closed for caseWhenNotNull', () => {
|
||||
class FakePlatform extends Platform {}
|
||||
const foreign = new FakePlatform();
|
||||
expect(() => caseWhenNotNull(foreign, 'u.a', 'u.b')).toThrow(/no implementation for platform FakePlatform/);
|
||||
});
|
||||
|
||||
// Task 1 fix review M1 (`PlaceShadowPicksRepository.countBySource`, PS5):
|
||||
// `countAll()`'s alias cannot be ordered by (`.orderBy({ count: 'desc' })`
|
||||
// throws "not existing property" — verified in SQLF-024's comment above);
|
||||
|
||||
Reference in New Issue
Block a user