mariadb: showAllTables lists tables from other databases
See original GitHub issueWhat are you doing?
With mariadb, showAllTables
lists all tables on the server (except system tables), rather than only those tables in the current database (which seems to be the behavior with other dialects, in particular mysql and postgres).
const sequelize = new Sequelize(config.dbUrl);
console.log(await sequelize.getQueryInterface().showAllTables());
What do you expect to happen?
[]
What is actually happening?
Tables from other databases on the server.
Notably, this means that dropAllTables
will attempt to clear out other databases, too.
The query seems to be using information_schema.tables
, but (unlike Postgres) information_schema is global in MySQL/MariaDB. (Switching dialect to mysql, which uses SHOW TABLES
, works.)
Dialect: mariadb
Dialect version: mariadb@2.0.3
Database version: 10.3
Sequelize version: master
Tested with latest release: Yes
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (5 by maintainers)
Top Results From Across the Web
4 Ways to List All Tables in a MariaDB Database
Below are four ways to list out the tables in a MariaDB database using SQL or the command line. The SHOW TABLES Command....
Read more >SHOW TABLES - MariaDB Knowledge Base
SHOW TABLES lists the non- TEMPORARY tables, sequences and views in a given database. The LIKE clause, if present on its own, indicates...
Read more >How do I list the tables in a MySQL database? - Alvin Alexander
To list/show the tables in a MySQL database: Log into your database using the mysql command line client; Issue the use command to...
Read more >How to show all the tables present in the database and server ...
We may sometimes require to get the list of all the tables present in our database. This can be done by using the...
Read more >Query to show all tables and their collation - Stack Overflow
Just so you can not select a table, you always need to know from which database it is. Name of the tables is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
🎉 This issue has been resolved in version 5.19.2 🎉
The release is available on:
Your semantic-release bot 📦🚀
Sequelize documentation about showAllTables indicate
So either documentation must be changed to “all existing tables in the schema”. or current implementation is ok.
I think there is some confusion here :
first compare with MySQL sequelize implementation. MySQL implementation in sequelize has no schema handling (a table ‘TABLE’ with schema ‘SCHEMA’ will result creating a table ‘SCHEMA_TABLE’ in current schema). MariaDB sequelize implementation result creating a SCHEMA.TABLE table. So thing are not really comparable.
When comparing with other DB that support schema in sequelize (mssql and postgresql) Other do :
So not sure what to do there.
If to be done, correction would be: