-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[12.x] Fix accessing Connection property in Grammar classes
#54487
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
[12.x] Fix accessing Connection property in Grammar classes
#54487
Conversation
|
Thanks for submitting a PR! Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
|
I've implemented passing Moving the |
|
@tpetry Thank you for reviewing and dislike😅. But this PR isn't just a styling fix, accessing the
|
|
@tpetry any further comments based on above? 👆 |
|
Not a big fan, but the package authors will find a way to make it work with the bc break here. And with the blueprint changes already merged (which I didn't see at that time) it'll already be some work. So break more stuff if it really simplifies some stuff in the future. |
The
Illuminate\Database\Grammarclass has required aConnection $connectionproperty since Laravel 10.x (via #46558), but it was passed viasetConnection()method to avoid signature changes in a patch release. Since then, many methods in theGrammarclasses have needed access to theConnectionproperty (mainly to retrieve config properties and compare driver versions). This PR does:Connection $connectionto theGrammarconstructor, instead of callingsetConnection()when instantiating.Connection::getTablePrefix()instead of having the$prefixproperty in theGrammarandBlueprintclasses.P.S. 1: This PR doesn’t require any upgrade guide for end-users.
P.S. 2: The
$connectionproperty was added to theBlueprintconstructor in Laravel 12.x via #51821, so now is a good time to fix it in theGrammarclass as well.Summary
prefix_indexesconfig property tosqliteconnection to be consistent with other DB driver connections.Connection $connectionproperty toIlluminate/Database/Grammar::__construct()method.Illuminate\Database\Connection::withTablePrefix()method.Illuminate\Database\Grammar::setConnection()method.Illuminate\Database\Schema\Builder::setConnection()method.$prefixproperty fromIlluminate\Database\Schema\Blueprint::__construct()method.Illuminate\Database\Grammar::getTablePrefix()method (UseIlluminate\Database\Connection::getTablePrefix()instead).Illuminate\Database\Grammar::setTablePrefix()method (UseIlluminate\Database\Connection::setTablePrefix()instead).Illuminate\Database\Schema\Blueprint::getPrefix()method (UseIlluminate\Database\Connection::getTablePrefix()instead).Blueprintwhenprefix_indexesis set tofalse.createDatabase()anddropDatabaseIfExists()methods toIlluminate\Database\Schema\Builderparent class (The same method was overridden on all inherited classes.)