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

Generating invalid SQL queries for IN/NOT IN filters #169

Closed
j4nr6n opened this issue Jan 12, 2023 · 4 comments
Closed

Generating invalid SQL queries for IN/NOT IN filters #169

j4nr6n opened this issue Jan 12, 2023 · 4 comments

Comments

@j4nr6n
Copy link

j4nr6n commented Jan 12, 2023

These are the queries that were generated in my case.

-- Current filters:
SELECT * FROM `test`.`table` WHERE `current_place` NOT IN '"sent", "escalated"' ORDER BY `id` LIMIT 300 OFFSET 0;

-- All checked filters:
SELECT * FROM `test`.`table` WHERE `current_place` NOT IN '"sent", "escalated"' ORDER BY `id` LIMIT 300 OFFSET 0;

If I try to apply the filter, I get

You have an error in your SQL syntax; check the manual that corresponds to your MySQL version for the right syntax to use near ''"sent", "escalated"' ORDER BY id LIMIT 300 OFFSET 0' at line 1

  1. Database version (Ex: PostgreSQL 10.0):
    MySQL 8.0

  2. TablePlus version (the number on the welcome or about screen, Ex: build 81):
    0.1 (192)

  3. Linux distro (Ex: Ubuntu 18.04):
    Ubuntu 22.04

  4. The steps to reproduce this issue:
    Connect to database and select a table. Click "Filters" and add an IN or NOT IN filter.

@j4nr6n j4nr6n changed the title TablePlus generates invalid SQL queries for IN/NOT IN filters. Generating invalid SQL queries for IN/NOT IN filters. Jan 12, 2023
@j4nr6n j4nr6n changed the title Generating invalid SQL queries for IN/NOT IN filters. Generating invalid SQL queries for IN/NOT IN filters Jan 12, 2023
@j4nr6n
Copy link
Author

j4nr6n commented Jan 30, 2023

Same thing seems to be happening with BETWEEN/NOT BETWEEN.

-- Current filters:
SELECT * FROM `test`.`table` WHERE `id` BETWEEN '"test" and "test"' LIMIT 300 OFFSET 0;

-- All checked filters:
SELECT * FROM `test`.`table` WHERE `id` BETWEEN '"test" and "test"' LIMIT 300 OFFSET 0;

@gleamx
Copy link

gleamx commented Mar 21, 2023

Same here:

Database version (Ex: PostgreSQL 10.0):
MySQL 5.6

TablePlus version (the number on the welcome or about screen, Ex: build 81):
0.1 (206)

Linux distro (Ex: Ubuntu 18.04):
Ubuntu 20.04

Can't use IN, NOT IN, BETWEEN, NOT BETWEEN !

@nettum
Copy link

nettum commented Dec 12, 2023

Congrats on a stable Linux release! 🎉

This is the only issue that have been bothering me for some time. Never got the IN / NOT IN and BETWEEN / NOT BETWEEN queries generated from the filters to work. It may be because I'm inputing something else that TablePlus are expecting though.

Examples:
image
resulting in query SELECT * FROM "public"."<table>" WHERE "id" IN '1000, 1005' ORDER BY "id" LIMIT 300 OFFSET 0;

image
resulting in query SELECT * FROM "public"."<table>" WHERE "id" IN '(1000, 1005)' ORDER BY "id" LIMIT 300 OFFSET 0;

The id field is an integer and my input are also comma-separated integers (this is how I would expect to input it...) so I would expect the query to be created without the single quotation marks, e.g. SELECT * FROM "public"."<table>" WHERE "id" IN (1000, 1005) ORDER BY "id" LIMIT 300 OFFSET 0;


Database version (Ex: PostgreSQL 10.0):
PostgreSQL 15.1

TablePlus version (the number on the welcome or about screen, Ex: build 81):
1.0.2 (236)

Linux distro (Ex: Ubuntu 18.04):
Ubuntu 22.04

@j4nr6n
Copy link
Author

j4nr6n commented Mar 18, 2024

This seems to have been fixed. 🤷‍♂️ If you type x and y in the BETWEEN/NOT BETWEEN, or (x, y) in the IN/NOT IN case, I now get valid SQL. No idea when it was fixed, but I'll take it.

@j4nr6n j4nr6n closed this as completed Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants