fix(db): type the move's value conversion and client for the server's compiler

Formats the two files the format gate listed.
This commit is contained in:
Maurice
2026-11-17 15:15:48 +01:00
parent 59f0c206bf
commit 03ee902c3d
4 changed files with 8 additions and 4 deletions
@@ -167,7 +167,8 @@ export async function copyTable(
const values: PostgresValue[] = [];
spec.columns.forEach((column, index) => {
const converted = convertValue(raw[index] as SqliteValue, column.kind);
if (converted.ok) {
// Narrowed by `in`: the server compiles without strictNullChecks, where `ok` does not narrow the union.
if (!('reason' in converted)) {
values.push(converted.value);
if (column.kind === 'integer' && beyondSafeInteger(converted.value)) result.unsafeIntegers++;
return;
@@ -25,6 +25,7 @@ import {
resolveIdentitySequences,
type PluginPlan,
} from './plugin-data';
import type { AbstractSqlConnection } from '@mikro-orm/sql';
import type { Kysely } from 'kysely';
@@ -281,7 +282,7 @@ export async function moveSqliteToPostgres(options: MoveOptions): Promise<MoveSu
warnings: [],
seconds: 0,
};
const db = options.orm.em.getConnection().getClient<object>();
const db = (options.orm.em.getConnection() as AbstractSqlConnection).getClient<object>();
let source: SqliteSource;
try {
source = SqliteSource.open(options.sqliteFile);
@@ -1,6 +1,6 @@
import { coalesceParam } from '../../dialect/sql-functions';
import { accommodationIdMatches } from './reservation-accommodation';
import type { DB } from '../../kysely/db';
import { accommodationIdMatches } from './reservation-accommodation';
import type { Platform } from '@mikro-orm/core';
import type { ExpressionBuilder, ExpressionWrapper, ReferenceExpression, SqlBool } from 'kysely';
@@ -69,7 +69,9 @@ describe('SQLite NULL order on Postgres', () => {
expect(withSqliteNullPosition('"t"."start_date" desc nulls first')).toBe('"t"."start_date" desc nulls first');
const platform = new SqliteNullOrderPlatform();
expect(platform.getOrderByExpression('"name"', 'ASC')).toEqual(['"name" asc nulls first']);
expect(platform.getOrderByExpression('"name"', 'desc', 'nocase')).toEqual(['"name" collate "nocase" desc nulls last']);
expect(platform.getOrderByExpression('"name"', 'desc', 'nocase')).toEqual([
'"name" collate "nocase" desc nulls last',
]);
expect(platform.getOrderByExpression('"name"', 'asc nulls last')).toEqual(['"name" asc nulls last']);
});
});