Skip to content

PSYCOPG drivers turns param into null #2657

@ExtReMLapin

Description

@ExtReMLapin

Hello

I started working back on implementing the psycopg driver for our app.

Started having this error : Syntax error on executing query: Invalid parameter name: 2

Line of code was :

cursor.execute(query=prefix+command, params=params)


{cypher}        UNWIND [{user_name: %(user_name)s, right: %(right_0)s}] AS node
        MERGE (n:USER_RIGHTS {user_name: node.user_name, right: node.right})
        return ID(n) as id
        

params
{'user_name': 'root', 'right_0': 'OWNER'}


I added debug prints to the psycopg driver :

          if (portal.sqlStatement != null) {
            final Object[] parameters = portal.parameterValues != null ? portal.parameterValues.toArray() : new Object[0];
            LogManager.instance().log(this, Level.INFO, "parameters: %s", Arrays.toString(parameters));

            resultSet = portal.sqlStatement.execute(database, parameters, createCommandContext());
          } else {
            LogManager.instance().log(this, Level.INFO, "language: %s", portal.language);
            LogManager.instance().log(this, Level.INFO, "query: %s", portal.query);
            LogManager.instance().log(this, Level.INFO, "parameters: %s", Arrays.toString(getParams(portal)));

            resultSet = database.command(portal.language, portal.query, server.getConfiguration(), getParams(portal));
          }

and I found out that :

some queries are executed correctly :

2025-10-14 16:30:40.740 INFO  [PostgresNetworkExecutor] parameters: [1, data_ingestion_pipeline]
2025-10-14 16:30:57.628 INFO  [PostgresNetworkExecutor] language: cypher
2025-10-14 16:30:57.629 INFO  [PostgresNetworkExecutor] query: MERGE (n:PIPELINE_CONFIG) ON CREATE SET n.pipelines = [$1] ON MATCH SET n.pipelines = [$1] RETURN n.pipelines as pipelines

2025-10-14 16:30:57.629 INFO  [PostgresNetworkExecutor] parameters: [1, data_ingestion_pipeline]

others are not, please see the NULL param, which leads to the cypher error posted at the start

2025-10-14 16:30:57.798 INFO  [PostgresNetworkExecutor] language: cypher
2025-10-14 16:30:57.798 INFO  [PostgresNetworkExecutor] query:         UNWIND [{user_name: $1, right: $2}] AS node
        MERGE (n:USER_RIGHTS {user_name: node.user_name, right: node.right})
        return ID(n) as id
        

2025-10-14 16:30:57.798 INFO  [PostgresNetworkExecutor] parameters: [1, 2, OWNER, null]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions