Open Grundik opened 1 year ago
Do you want to work on a fix?
There is a simple fix: just remove special handling of 'public' namespace in PostgreSQLSchemaManager->_getPortableSequenceDefinition
. But that will probably open can of worms, so I dont know how to reliably fix that without bunch of BC break problems.
Bug Report
Summary
Schema introspection incorrectly parses sequences from namespace
public
, if current namespace is other thanpublic
.Current behaviour
Doctrine\DBAL\Schema\PostgreSQLSchemaManager#_getPortableSequenceDefinition just removes schema name if it is
public
: https://github.com/doctrine/dbal/blob/3.6.x/src/Schema/PostgreSQLSchemaManager.php#L357but later on, when sequences are added to the schema, if there are no namespace specified, it is filled from default one: https://github.com/doctrine/dbal/blob/3.6.x/src/Schema/Schema.php#L206
and deeper into https://github.com/doctrine/dbal/blob/3.6.x/src/Schema/AbstractAsset.php#L130:
But! This new schema are coming from
search_path
: https://github.com/doctrine/dbal/blob/3.6.x/src/Schema/AbstractSchemaManager.php#L1678It means, that sequence changes its namespace from
public
to one, which is insearch_path
.Due to this behaviour, schema introspection are not getting database schema correctly, and even fails if there are sequences with same name in different namespaces.
How to reproduce
Create database, namespace, and then two sequences:
That would result an error:
Expected behaviour
Namespace names on sequences should be preserved, introspection of multi-namespaced databases should not fail.