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

[BUG] ShowTablesFrom returns all tables on PostgreSQL #167

Open
MateusBMP opened this issue Jun 26, 2024 · 0 comments
Open

[BUG] ShowTablesFrom returns all tables on PostgreSQL #167

MateusBMP opened this issue Jun 26, 2024 · 0 comments

Comments

@MateusBMP
Copy link

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:

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

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:

  • Laravel 11
  • PHP 8.3
  • PostgreSQL database

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.

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

1 participant