Protoqol / Prequel

Prequel for Laravel. Clear and concise database management. Unfortunately, not actively maintained due to time constraints.
https://packagist.org/packages/protoqol/prequel
MIT License
1.54k stars 96 forks source link

[BUG] ShowTablesFrom returns all tables on PostgreSQL #167

Open MateusBMP opened 2 months ago

MateusBMP commented 2 months ago

The ShowTablesFrom for pgsql database type will return always the list for all the tables, not only the specific requested $databaseName. This code stays here:

https://github.com/Protoqol/Prequel/blob/9b37d8ca1948dffa59dbdc67edc07d0af7864f3c/src/Database/SequelAdapter.php#L91-L94

To Reproduce:

  1. Go to home page
  2. See the database tables list

Expected behavior: Returns only the tables from the requested database. I'll suggest this change:

case "pgsql":
    return 'SELECT table_name FROM information_schema.tables WHERE ' .
        'table_catalog=\'' . $databaseName . '\' AND ' .
        'table_schema=\'' . config("database.connections.pgsql.schema") . '\' ' .
        'ORDER BY table_name;';

Test context:

Additional context: The document doesn't talk about the config("database.connections.pgsql.schema") call in same method. I'll suggest to add this into the README or use the value public as a default value.