[11.x] Fix inconsistent database parsing on PostgreSQL#49148
Merged
taylorotwell merged 5 commits intolaravel:masterfrom Dec 13, 2023
Merged
[11.x] Fix inconsistent database parsing on PostgreSQL#49148taylorotwell merged 5 commits intolaravel:masterfrom
taylorotwell merged 5 commits intolaravel:masterfrom
Conversation
Member
|
@hafezdivandari are you still working on this? |
Contributor
Author
Contributor
Author
|
@driesvints would you please merge '10.x' into master? cc @crynobone |
Member
|
@hafezdivandari will do as soon as all of the fixes PRs that are open are merged. |
Member
|
@hafezdivandari done now |
This was referenced Feb 7, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As explained on #49020,
Schema::hasTable()usesSchema::getTables()on all database drivers except PostgreSQL, becauseSchema::hasTable()on PostgreSQL is the only function on the schema/grammar/builder that accepts 3-parts references likeSchema::hasTable('database.schema.table'). This is an inconsistent behavior, as other functions and non of the other database drivers support this syntax.This PR fixes this by throwing an exception if 3-parts reference is mistakenly passed to
Schema::hasTable()and also changesSchema::hasTables()on PostgreSQL to useSchema::getTables()just like other databases.Note: Passing 2-parts reference or just table name to these functions on PostgreSQL works as expected as before:
Upgrade Guide
Likelihood Of Impact: Very Low
The
Schema::hasTable()on PostgreSQL database doesn't accept declaring database name by passing a 3-parts reference anymore and will throw an exception. Therefore, if you were using 3-parts reference on these methods you may useconnection()to declare the database instead: