-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[10.x] Fix using schema names in SQL server #49929
[10.x] Fix using schema names in SQL server #49929
Conversation
@arjenvanoostrum Are you trying to fix something on this PR or add support for specifying schema on SQL Server? I know that SQL Server supports specifying schema just like PostgreSQL, but it would be a breaking change to add support for this on |
Hi @hafezdivandari, thanks for your quick reply. Up until the 10.34 release it was possible to use schema names in
As of 10.34 this is no longer possible which was a breaking change for us. So I think it should be a fix and no added support. We have to halt updates to our apps. I tried to fix it without reverting your work in #49020 and in a way that is similar to how Postgres Builder deals with this to improve the framework. I just pushed a last version but seem to have some trouble fixing the style, will look at that tomorrow |
…o bugfix-sqlserver-schema-use # Conflicts: # tests/Database/DatabasePostgresSchemaBuilderTest.php
@arjenvanoostrum this PR is breaking change and won't get merge to a patch release. I'll send another PR to fix this. But please note that using schema names on SQL Server were never actually supported / tested on Laravel and few methods conditionally work with schema names (e.g. using table prefix will break this), the question is, are you actually using |
@hafezdivandari Yes we do use And should other parts of the framework be adjusted? I am thinking of the |
@arjenvanoostrum good, I'll send a PR for master then, we can fully support schema name on almost all methods on Laravel 11. |
Hello! Thanks for the mention here, and apologies for the slow reply. With regard to the use-case for It's been a few years since I've looked at any of this, but my recollection is that there are valid use-cases for wanting to see if a given schema contains a table when said schema is not necessarily (or even explicitly) within the database that is defined on the connection. I would have to dig deeper for a specific example in my own code, but my recollection is that we had a need to perform this check against a different database (not the one defined on the connection in question). @arjenvanoostrum When you say
Are you sure? The query looks to include framework/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php Lines 71 to 79 in 9448e01
Again, I'd have to run some of my custom integration tests, ideally against these PRs, and revisit this to provide more information. |
Hi @hafezdivandari I'll await your PR than, thanks for picking up. I'll close this one. And hi @cbj4074! I didn't test it on a live PostgresSQL before, though it should behave like that accoring to the docs (https://www.postgresql.org/docs/current/infoschema-tables.html) which state that it will always be the current database. So, when testing with a docker Postgres: So, trying to use this |
@arjenvanoostrum I just sent another PR to 11.x to bring full support for non-default schema names on pgsql and sqlsrv, you may check #50019 and #49148 |
The change in #49020 resulted in breaking changes for users utilizing schema's in SQL server. Much like Postgres, SQL server has the ability to store tables and other objects in different schemas in the database. Forementiond PR resulted in:
hasTable()
andhasColumn
when checking a table that exists in another schemahasTable()
andhasColumn
when checking a table in a non-default schemaThis PR fixes these cases and adds tests to the class. As there are quite some similarities with Postgres, I reused some of these methods.
@hafezdivandari , I noticed your comment on the PR regarding the Postgresql:
I agree with you this is non-standard and even so, not possible. As the postgres docs state: https://www.postgresql.org/docs/current/infoschema-tables.html
The existing
compileTableExists
will only find records in the current database. @cbj4074 Maybe you can explain the mentioned use case?