mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 11:49:59 +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,
|
deleteColumnQuery,
|
||||||
extractInsertedIds,
|
extractInsertedIds,
|
||||||
extractReturningData,
|
extractReturningData,
|
||||||
getPlaceholder,
|
|
||||||
normalizeRows,
|
normalizeRows,
|
||||||
normalizeValue,
|
normalizeValue,
|
||||||
quoteIdentifier,
|
quoteIdentifier,
|
||||||
@@ -226,12 +225,15 @@ export class DataStoreRowsRepository {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dbType = this.dataSource.options.type;
|
const table = this.toTableName(dataStoreId);
|
||||||
const quotedTableName = quoteIdentifier(this.toTableName(dataStoreId), dbType);
|
|
||||||
const placeholders = ids.map((_, index) => getPlaceholder(index + 1, dbType)).join(', ');
|
await this.dataSource
|
||||||
const query = `DELETE FROM ${quotedTableName} WHERE id IN (${placeholders})`;
|
.createQueryBuilder()
|
||||||
|
.delete()
|
||||||
|
.from(table, 'dataStore')
|
||||||
|
.where({ id: In(ids) })
|
||||||
|
.execute();
|
||||||
|
|
||||||
await this.dataSource.query(query, ids);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -261,7 +261,3 @@ export function normalizeValue(
|
|||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPlaceholder(index: number, dbType: DataSourceOptions['type']): string {
|
|
||||||
return dbType.includes('postgres') ? `$${index}` : '?';
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user