Add query parameters for CrateDB, PostgresDB, TimescaleDB and QuestDB (Parametrized Queries) (#1577)

* Adding support to ParameterizedQuery on Postgres Node

* Created another parameter to toggle on replacement so it's clear to users what is happening.

* Fixed lint issues

*  Formatting

* Improvements to questDB node so it is more consistent

* Fixed lint issues

* Fixed typing issue

*  Apply suggestions BHesseldieck

Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>

* Standardized output for postgres and postgres-like nodes

This changes the behavior of CrateDB, Postgres, QuestDB and TimescaleDB
nodes.

The Execute Query operation used to execute multiple queries but return
the result from only one of the queries.

This change causes the node output to containt results from all queries
that ran, making the behavior more consistent across all n8n.

* Fixing lint issues

*  Minor improvements

*  Fix breaking changes files

Co-authored-by: Gustavo Arjones <gustavo.arjones@ank.app>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Jan <janober@users.noreply.github.com>
Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
This commit is contained in:
Omar Ajoue
2021-05-01 00:35:34 +02:00
committed by GitHub
parent 4cf8055224
commit fc54f7c82b
6 changed files with 105 additions and 25 deletions

View File

@@ -73,9 +73,9 @@ export class QuestDb implements INodeType {
},
},
default: '',
placeholder: 'SELECT id, name FROM product WHERE id < 40',
placeholder: 'SELECT id, name FROM product WHERE quantity > $1 AND price <= $2',
required: true,
description: 'The SQL query to execute.',
description: 'The SQL query to execute. You can use n8n expressions or $1 and $2 in conjunction with query parameters.',
},
// ----------------------------------
@@ -176,6 +176,21 @@ export class QuestDb implements INodeType {
'See the docs for more examples',
].join('<br>'),
},
{
displayName: 'Query Parameters',
name: 'queryParams',
type: 'string',
displayOptions: {
show: {
'/operation': [
'executeQuery',
],
},
},
default: '',
placeholder: 'quantity,price',
description: 'Comma separated list of properties which should be used as query parameters.',
},
],
},
{
@@ -215,7 +230,7 @@ export class QuestDb implements INodeType {
const db = pgp(config);
let returnItems = [];
let returnItems: INodeExecutionData[] = [];
const items = this.getInputData();
const operation = this.getNodeParameter('operation', 0) as string;