Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL Node: Fixed String $1 Misinterpreted as Placeholder in Execute Query Operation #9680

Open
tumf opened this issue Jun 9, 2024 · 3 comments
Labels
in linear Issue or PR has been created in Linear for internal review

Comments

@tumf
Copy link
Contributor

tumf commented Jun 9, 2024

Bug Description

When using the PostgreSQL node in n8n with the "Execute Query" operation, if the query contains the fixed string $1, it is incorrectly interpreted as a placeholder, causing an error.

Example Query:

select '$1'

Error Message:

Variable $1 out of range. Parameters array length: 0
Failed query: select '$1'

This query, when executed directly in PostgreSQL, correctly returns the string $1. However, in n8n, it is treated as a placeholder, leading to the mentioned error.

To Reproduce

  1. Create a workflow in n8n.
  2. Add a PostgreSQL node.
  3. Set the operation to "Execute Query".
  4. Use the query:
    select '$1'
    
  5. Execute the workflow.

Expected behavior

The query select '$1' should return the string $1 when executed in the PostgreSQL node, similar to how it behaves when run directly in PostgreSQL.

Operating System

Ubuntu 24.04. LTS

n8n Version

1.44.1

Node.js Version

20.13.1

Database

PostgreSQL

Execution mode

queue

@Joffcom Joffcom added the in linear Issue or PR has been created in Linear for internal review label Jun 17, 2024
@Joffcom
Copy link
Member

Joffcom commented Jun 17, 2024

Thanks for the report, I have managed to reproduce this and have created NODE-1416 as the internal ticket to get this fixed. Out of interest and so we can set a priority to it... Do you use $x a lot in your queries?

@tumf
Copy link
Contributor Author

tumf commented Jun 21, 2024

I think this issue is critical for PostgreSQL becasue the issue prevents the execution of very common SQL such as the following example:
insert into comments (id, text) values (2, "His efforts have resulted in a $1000 salary increase.”)

Of course, this problem can be bypassed by using a PREPARED STATEMENT as follows.
insert into comments (id, text) values (2, $1)
Query parameters: "His efforts have resulted in a $1000 salary increase.”

@Joffcom
Copy link
Member

Joffcom commented Jun 24, 2024

That value makes perfect sense, This is in the queue to be picked up so should be resolved soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in linear Issue or PR has been created in Linear for internal review
Projects
None yet
Development

No branches or pull requests

2 participants