[11.x] Fix inconsistent database parsing on PostgreSQL #49148
Merged
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: