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

Wrong parse of search path for table in different schemas of PostgreSQL Builder. #41213

Closed
Manriel opened this issue Feb 24, 2022 · 1 comment · Fixed by #41215
Closed

Wrong parse of search path for table in different schemas of PostgreSQL Builder. #41213

Manriel opened this issue Feb 24, 2022 · 1 comment · Fixed by #41215
Labels

Comments

@Manriel
Copy link

Manriel commented Feb 24, 2022

  • Laravel Version: 9.0.x
  • PHP Version: not related with php version
  • Database Driver & Version: not related with driver

Description:

$this->connection->getConfig('search_path') ?: 'public'

I suppose that this one line should be like in other places of the same file:
$this->connection->getConfig('search_path') ?: $this->connection->getConfig('schema')

Otherwise, if you check table exists at postgres schema from env variable DB_SCHEMA referenced in the config, but it checks default postgres schema "public", ignoring the configuration.

Steps To Reproduce:

  1. Create table "migrations" at default postgres schema public
  2. Set env variable DB_SCHEMA with value different from "public" that do not contain any tables (the schema should exist at the DB, of course)
  3. Run command php artisan migrate.

You'll see that it will fail with error that it can't reference "migrations" table that not exist.
If you turn on SQL queries log, you'll see that it have checked table "migrations" in schema "public", found it exists and try to make a query to that table in schema you referenced at the env variable DB_SCHEMA that still does not exist.

@derekmd
Copy link
Contributor

derekmd commented Feb 24, 2022

You'll want to fill out the issue template or this will be closed. When fixing #41088 I didn't even see parseSearchPath() is (mostly) copypasta'd into a second class so that must be fixed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants