fix(Postgres Node): Accommodate null values in query parameters for expressions (#13544)

This commit is contained in:
Dana
2025-02-27 16:39:08 +01:00
committed by GitHub
parent 0fb66076ba
commit 6c266acced
4 changed files with 59 additions and 3 deletions

View File

@@ -14,7 +14,12 @@ import type {
QueriesRunner,
QueryWithValues,
} from '../../helpers/interfaces';
import { isJSON, replaceEmptyStringsByNulls, stringToArray } from '../../helpers/utils';
import {
evaluateExpression,
isJSON,
replaceEmptyStringsByNulls,
stringToArray,
} from '../../helpers/utils';
import { optionsCollection } from '../common.descriptions';
const properties: INodeProperties[] = [
@@ -84,8 +89,9 @@ export async function execute(
const resolvables = getResolvables(rawValues);
if (resolvables.length) {
for (const resolvable of resolvables) {
const evaluatedExpression =
this.evaluateExpression(`${resolvable}`, index)?.toString() ?? '';
const evaluatedExpression = evaluateExpression(
this.evaluateExpression(`${resolvable}`, index),
);
const evaluatedValues = isJSON(evaluatedExpression)
? [evaluatedExpression]
: stringToArray(evaluatedExpression);

View File

@@ -30,6 +30,16 @@ export function isJSON(str: string) {
}
}
export function evaluateExpression(expression: NodeParameterValueType) {
if (expression === undefined) {
return '';
} else if (expression === null) {
return 'null';
} else {
return typeof expression === 'object' ? JSON.stringify(expression) : expression.toString();
}
}
export function stringToArray(str: NodeParameterValueType | undefined) {
if (str === undefined) return [];
return String(str)