Skip to content

Commit

Permalink
Merge branch 'hotfix/fix-pg-queries' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Navaneeth-pk committed Aug 25, 2021
2 parents b76f18b + 98da31d commit 0981fcc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/plugins/datasources/postgresql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class PostgresqlQueryService implements QueryService {
query = queryOptions.query;
}

result = await pool.query(queryOptions.query);
result = await pool.query(query);

return {
status: 'ok',
Expand Down Expand Up @@ -78,19 +78,19 @@ export default class PostgresqlQueryService implements QueryService {
const primaryKey = queryOptions['primary_key_column'];
const records = queryOptions['records'];

for( const record of records ) {
for(const record of records ) {
queryText = `${queryText} UPDATE ${tableName} SET`;

for(const key of Object.keys(record)) {
if(key !== primaryKey) {
queryText = ` ${queryText} ${key} = '${record[key]}', `;
queryText = ` ${queryText} ${key} = '${record[key]}',`;
}
}

queryText = queryText.slice(0, -1);
queryText = `${queryText} WHERE ${primaryKey} = ${record[primaryKey]};`;
}

return queryText.trim();

}
}

0 comments on commit 0981fcc

Please sign in to comment.