refactor(core): Use query builder at data table deletes (no-changelog) (#18795)

This commit is contained in:
Jaakko Husso
2025-08-26 16:49:56 +03:00
committed by GitHub
parent 71ff4d8b6b
commit d892574989
2 changed files with 8 additions and 10 deletions

View File

@@ -17,7 +17,6 @@ import {
deleteColumnQuery,
extractInsertedIds,
extractReturningData,
getPlaceholder,
normalizeRows,
normalizeValue,
quoteIdentifier,
@@ -226,12 +225,15 @@ export class DataStoreRowsRepository {
return true;
}
const dbType = this.dataSource.options.type;
const quotedTableName = quoteIdentifier(this.toTableName(dataStoreId), dbType);
const placeholders = ids.map((_, index) => getPlaceholder(index + 1, dbType)).join(', ');
const query = `DELETE FROM ${quotedTableName} WHERE id IN (${placeholders})`;
const table = this.toTableName(dataStoreId);
await this.dataSource
.createQueryBuilder()
.delete()
.from(table, 'dataStore')
.where({ id: In(ids) })
.execute();
await this.dataSource.query(query, ids);
return true;
}

View File

@@ -261,7 +261,3 @@ export function normalizeValue(
return value;
}
export function getPlaceholder(index: number, dbType: DataSourceOptions['type']): string {
return dbType.includes('postgres') ? `$${index}` : '?';
}