Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[11.x] Use Default Schema Name on SQL Server #50855

Merged

Conversation

hafezdivandari
Copy link
Contributor

@hafezdivandari hafezdivandari commented Mar 30, 2024

Fixes #50842

On SQL Server, Schema methods were always using dbo schema as default. This causes problem in a rare condition that user manually changes the default schema (e.g by calling alter user my_user with default_schema = my_schema). This PR fixes that by utilizing the actual default schema (not always dbo).

Copy link

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.

@hafezdivandari hafezdivandari marked this pull request as ready for review March 30, 2024 18:20
@hafezdivandari hafezdivandari marked this pull request as draft March 31, 2024 13:50
@hafezdivandari hafezdivandari marked this pull request as ready for review March 31, 2024 14:17
@taylorotwell taylorotwell merged commit 9e7ba35 into laravel:11.x Apr 1, 2024
28 checks passed
@hafezdivandari hafezdivandari deleted the 11.x-get-default-schema-sqlsrv branch April 1, 2024 00:31
@peterpeep
Copy link

Hi, @hafezdivandari

Is it possible to set the default schema for SQLSRV now using config/database.php
If so then how? If not then is there any future plan for that?

Thanks!!!

@hafezdivandari
Copy link
Contributor Author

Hi @peterpeep, afaik SQL Server doesn't support setting default schema when establishing a connection (unlike PostgreSQL). The only way is to use alter user command on a not-admin user. So it seems there is no consistent way to implement this for SQL Server rn?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
3 participants