You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even though the Schema object has its tables and sequences indexed by their qualified names, the schema comparison uses unqualified names for the objects in the default schemas.
This is logic is lossy by definition and therefore leads to conflicts. Here's a reproducer on PostgreSQL (a similar scenario could be used to reproduce the issue on SQLite and SQL Server as well):
From the source schema's perspective where the default namespace is test, the t and public.t names are different because t resolves to test.t, public.t is already qualified, and "test.t" ≠ "public.t" .
By default, the default PostgreSQL schema is public. When the comparator compares the schemas, it applies Table::getShortestName() to table names and drops the default names namespace from the name. Thus, it turns test.t back into t. Eventually, the schema manager attempts to create both tables t and public.t and fails because they both resolve to the same qualified name public.t in the destination database.
The library should use unqualified names only in its consumer-facing API and only as a convenience feature (similar to SQL). Once an unqualified name has been resolved to a qualified one, this information should not be discarded. From the lossiness perspective, the current logic is as absurd as dropping units before comparing lengths and concluding that 5 feet is greater than 3 meters.
If the destination platform supports namespaces, the comparator should use qualified names for comparing schema objects.
The text was updated successfully, but these errors were encountered:
Even though the
Schema
object has its tables and sequences indexed by their qualified names, the schema comparison uses unqualified names for the objects in the default schemas.dbal/src/Schema/Schema.php
Lines 186 to 195 in bb16de1
dbal/src/Schema/Comparator.php
Lines 54 to 56 in 0f0398a
This is logic is lossy by definition and therefore leads to conflicts. Here's a reproducer on PostgreSQL (a similar scenario could be used to reproduce the issue on SQLite and SQL Server as well):
From the source schema's perspective where the default namespace is
test
, thet
andpublic.t
names are different becauset
resolves totest.t
,public.t
is already qualified, and "test.t" ≠ "public.t" .By default, the default PostgreSQL schema is
public
. When the comparator compares the schemas, it appliesTable::getShortestName()
to table names and drops the default names namespace from the name. Thus, it turnstest.t
back intot
. Eventually, the schema manager attempts to create both tablest
andpublic.t
and fails because they both resolve to the same qualified namepublic.t
in the destination database.The library should use unqualified names only in its consumer-facing API and only as a convenience feature (similar to SQL). Once an unqualified name has been resolved to a qualified one, this information should not be discarded. From the lossiness perspective, the current logic is as absurd as dropping units before comparing lengths and concluding that 5 feet is greater than 3 meters.
If the destination platform supports namespaces, the comparator should use qualified names for comparing schema objects.
The text was updated successfully, but these errors were encountered: