feat(database): modify PostgreSQL insert query to return the entire inserted row for tables without an "id" column
All checks were successful
Build & Push Docker Image / build (push) Successful in 6m35s
All checks were successful
Build & Push Docker Image / build (push) Successful in 6m35s
This commit is contained in:
@@ -83,7 +83,9 @@ class PostgresAdapter {
|
|||||||
let pgSql = convertPlaceholders(sql);
|
let pgSql = convertPlaceholders(sql);
|
||||||
const isInsert = /^\s*INSERT/i.test(pgSql);
|
const isInsert = /^\s*INSERT/i.test(pgSql);
|
||||||
if (isInsert && !/RETURNING/i.test(pgSql)) {
|
if (isInsert && !/RETURNING/i.test(pgSql)) {
|
||||||
pgSql += ' RETURNING id';
|
// Some tables (e.g. settings, oauth_states) have no "id" column.
|
||||||
|
// Return the inserted row generically and read id only when present.
|
||||||
|
pgSql += ' RETURNING *';
|
||||||
}
|
}
|
||||||
const result = await this.pool.query(pgSql, params);
|
const result = await this.pool.query(pgSql, params);
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user