-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Deprecate mixing qualified and unqualified names #6677
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
Deprecate mixing qualified and unqualified names #6677
Conversation
@@ -228,7 +228,10 @@ public function testHasTableForQuotedAsset(): void | |||
|
|||
public function testHasNamespace(): void | |||
{ | |||
$schema = new Schema(); | |||
$schemaConfig = new SchemaConfig(); | |||
$schemaConfig->setName('public'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and other similarly modified tests operate unqualified and qualified names. From now on, this is only allowed if the schema has a default namespace configuration.
* Indicates whether the schema uses unqualified names for its objects. Once this flag is set to true, it won't be | ||
* unset even after the objects with unqualified names have been dropped from the schema. | ||
*/ | ||
private bool $usesUnqualifiedNames = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this flag write once? Should it be marked as such by using @readonly
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not exactly write once, it can be flipped once from false
to true
. @readonly
might be confusing, if the reader assumes the same contract as the one provided by the readonly
modifier:
[...] which prevents modification of the property after initialization.
This flag is initialized as f
8000
alse
and can be modified at any point in time to true
or never modified.
Technically, each of the three commits could be contributed as a separate pull request but I'll publish them altogether in the interest of time as each of them depends on the previous one.
1. Population of the current SQL Server schema
Technically, the fact that the current SQL Server schema isn't populated during introspection is a bug. Once introspected, a PostgreSQL schema allows referencing its objects by unqualified or qualified name but the SQL Server schema doesn't. This commit addresses this issue and reworks an existing test to cover this scenario.
2. Deprecation of mixing qualified and unqualified names in a schema
Currently, a schema allows registering objects with a mixture of unqualified names (e.g.
customers
) and qualified names (e.g.public.customers
). It compares names as strings, so in the absence of a default schema name, "customers" ≠ "public.customers", however, it's a logical error because these two values are incomparable (again, similar to "5" and "5 meters").In order to make the schema API more robust, mixing incomparable types of names is deprecated.
Using unqualified names
Unqualified names can be used to add objects to or reference objects in a schema only if doesn't contain objects with qualified names or has a default namespace configuration.
Using qualified names
Qualified names can be used to add objects to or reference objects in a schema only if doesn't contain objects with unqualified names.
Considered alternatives
Whether a given schema uses unqualified or qualified names is determined at runtime. An even more robust approach would be parameterize the schema class with the type of its objects' names and use this information for static analysis. However, the type of the names is defined by the target database platform, which is determined at runtime based on connection parameters, so the static typing is not feasible.
3. Deprecation of
AbstractAsset::isIdentifierQuoted()
Once these changes are merged into 5.0.x, it will be possible to stop using
AbstractAsset::isIdentifierQuoted()
. At that point, we should be able to remove it.The problem with this method is that it accepts a name that potentially consists of multiple identifiers and returns the value based on whether the first one is quoted. This is incorrect as each identifier may or may not be quoted individually.