mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
refactor(core): Use query builder at data table deletes (no-changelog) (#18795)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,3 @@ export function normalizeValue(
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
export function getPlaceholder(index: number, dbType: DataSourceOptions['type']): string {
|
||||
return dbType.includes('postgres') ? `$${index}` : '?';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user