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

SQL query with bindings for IN values no longer work #4978

Closed
mjashanks opened this issue Mar 21, 2022 Discussed in #4963 · 5 comments
Closed

SQL query with bindings for IN values no longer work #4978

mjashanks opened this issue Mar 21, 2022 Discussed in #4963 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@mjashanks
Copy link
Member

mjashanks commented Mar 21, 2022

A change in the way SQL parameters work has made the SQL ... WHERE something IN {{ values }} impossible.

Original poster reported in MySQL, and I reproduced in Postgres

Discussed in #4963

Originally posted by micebrain March 19, 2022
Hi,
I updated my app to v1.0.90 and found that SQL queries that has value binding to integer column is giving error:

error: invalid input syntax for type integer: "1,2"

I figured out that this only happened to queries that uses the in expression with multiple values. And example of the query is something like

SELECT * FROM customer WHERE id in ({{ customer_ids }});

with the customer_ids = 1,2

My expectation of the template output would be

SELECT * FROM customer WHERE in (1,2);

But the error message seems to indicate that it is now rendering as

SELECT * FROM customer WHERE in ('1,2');

How can I change this behaviour?

@mjashanks mjashanks added the bug Something isn't working label Mar 21, 2022
@mjashanks mjashanks changed the title SQL query with bindings for integer column giving error SQL query with bindings for IN values no longer work Mar 21, 2022
mike12345567 added a commit that referenced this issue Mar 21, 2022
@mike12345567 mike12345567 self-assigned this Mar 21, 2022
@micebrain
Copy link

Hi,
I updated to the latest version v1.0.99, however this it didn't seems to fix the issue.
I still get the same error in my test.

Screenshot 2022-04-01 at 20 34 18

@mike12345567
Copy link
Collaborator

Hi @micebrain - could you provide an example of your query to test?

@micebrain
Copy link

Hi @mike12345567 sure, it's actually pretty simple. Here is the screenshot of the configured query

Screenshot 2022-04-03 at 08 18 46

@mike12345567
Copy link
Collaborator

Hi @micebrain - can you try this query without the parentheses around the binding e.g. WHERE id in {{ customer_ids }}; - we've changed how Budibase manages these kind of statements and it will now automate the inclusion of the braces.

I will see if Budibase can detect that they've already been included in the query and not add them if they are already there - but I think removing them should fix your query.

@micebrain
Copy link

Hi @mike12345567
Yes that solved the problem. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants