1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

fix: update or delete rows with more than one primary key

This commit is contained in:
2021-03-21 13:00:27 +01:00
parent db47b4040a
commit 22a8c25717
4 changed files with 27 additions and 16 deletions

View File

@ -328,6 +328,8 @@ export class PostgreSQLClient extends AntaresCore {
* @returns {Array}
*/
async getTableByIDs (ids) {
if (!ids) return;
const { rows } = await this.raw(`
SELECT relid AS tableid, relname, schemaname FROM pg_statio_all_tables WHERE relid IN (${ids})
UNION
@ -1206,7 +1208,7 @@ export class PostgreSQLClient extends AntaresCore {
const orderByRaw = orderByArray.length ? `ORDER BY ${orderByArray.join(', ')} ` : '';
// LIMIT
const limitRaw = this._query.limit.length ? `LIMIT ${this._query.limit.join(', ')} ` : '';
const limitRaw = selectArray.length && this._query.limit.length ? `LIMIT ${this._query.limit.join(', ')} ` : '';
return `${selectRaw}${updateRaw ? 'UPDATE' : ''}${insertRaw ? 'INSERT ' : ''}${this._query.delete ? 'DELETE ' : ''}${fromRaw}${updateRaw}${whereRaw}${groupByRaw}${orderByRaw}${limitRaw}${insertRaw}`;
}