TablePlus / TablePlus-Linux

TablePlus Linux issue tracker
https://tableplus.com
293 stars 30 forks source link

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

Closed j4nr6n closed 6 months ago

j4nr6n commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 9 months ago

Congrats on a stable Linux release! :tada:

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 commented 6 months ago

This seems to have been fixed. :man_shrugging: 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.