antares icon indicating copy to clipboard operation
antares copied to clipboard

Cannot show tables with a SQL query which uses a LIKE clause

Open btry opened this issue 2 years ago • 2 comments

Describe the bug Trying to execute a SHOW TABLES query like the following, I get the following error

"Error: Table 'mydb.tables' doesn't exist"

The SQL looks like:

SHOW TABLES LIKE 'foo_%'

In the console I notice the following queries:

SHOW TABLES LIKE 'foo_%'
SELECT * FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = 'mydb' AND `TABLE_NAME` = 'tables' ORDER BY `ORDINAL_POSITION` ASC
SHOW CREATE TABLE `mydb`.`tables`
SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = 'mydb AND `TABLE_NAME` = 'tables' AND `REFERENCED_TABLE_NAME` IS NOT NULL
SELECT * FROM `information_schema`.`REFERENTIAL_CONSTRAINTS` WHERE `CONSTRAINT_SCHEMA` = 'mydb' AND `TABLE_NAME` = 'tables' AND `REFERENCED_TABLE_NAME` IS NOT NULL

To Reproduce Steps to reproduce the behavior:

  1. Create a database mydb
  2. Create one or several tables having a neme beginning with foo_
  3. Open a new tab to write and execute the query SHOW TABLES LIKE 'foo_%'
  4. see the error, and see the console log

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Application (please complete the following information):

  • App client MySQL
  • App version 0.5.16
  • Installation source: snap package

Environment (please complete the following information):

  • OS name: Ubuntu
  • OS version 22.04
  • DB name Mysql
  • DB version 8.0.30

Additional context Add any other context about the problem here.

btry avatar Sep 06 '22 06:09 btry

Hi @btry , In Antares every tab targets a schema. In your case you are probably targeting mydb schema.

If you target information_schema everything should work. image

Fabio286 avatar Sep 06 '22 07:09 Fabio286

Hi

Thanks for your reply.

If i switch to informations_schema the query works, but I want to see the tables in the DB mydb. It looks like Antares tries to get some metadata for a table having a name picked from the SQL query. With SHOW TABLES it seems to me not relevant as the table name is usually not present, or in my case only a prefix string.

btry avatar Sep 06 '22 07:09 btry

This issue is probably related to https://github.com/antares-sql/antares/issues/461 and should be fixed with 88408da745e45c70de977bc4270e5f61825be65f.

From next release please let me know if you continue to notice the problem.

Fabio286 avatar Oct 17 '22 12:10 Fabio286

Hi,

With version 0.5.19 it now works as expected. Thank you.

btry avatar Oct 24 '22 06:10 btry