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
Deprecations in schema- and namespace-related APIs #4548
Conversation
FROM information_schema.schemata | ||
WHERE schema_name NOT LIKE 'pg\_%' | ||
AND schema_name != 'information_schema' | ||
SQL |
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.
PHP 7.3 allows you to use indention for nowdoc here and below 🙂
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.
I have mixed feelings about this feature:
- The left margin of the block is not clearly visible.
- It's usually a program within a program, so it's fine that it's not indented the same as the outer one.
So far, it's consistent with the rest of the codebase (except for #4483). Let's reconsider this at the coding standard level first.
|
||
self::assertContains('test_create_schema', $namespaces); | ||
/** | ||
* @return iterable<list<mixed>> |
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.
dataproviders return signature should match the return iterable<array{…}>
, where the …
part is build from the phpdoc of the method that use it, so here return iterable<array{callable(AbstractSchemaManager): list<string>}>
?
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.
ERROR: InvalidReturnType - tests/Functional/Schema/SchemaManagerFunctionalTestCase.php:180:16 - The declared return type 'iterable<mixed, array{callable(Doctrine\DBAL\Schema\AbstractSchemaManager):list}>' for Doctrine\DBAL\Tests\Functional\Schema\SchemaManagerFunctionalTestCase::listSchemaNamesMethodProvider is incorrect, got 'Generator<int, array{impure-Closure(Doctrine\DBAL\Schema\AbstractSchemaManager):array<array-key, string>|impure-Closure(Doctrine\DBAL\Schema\AbstractSchemaManager):list}, mixed, void>' (see https://psalm.dev/011)
* @return iterable<array{callable(AbstractSchemaManager): list}>
I agree in general but it would be much better if it was validated by the static analysis. Otherwise, it helps only when implementing the data provider but isn't used by the caller.
Similarly to the above comment, let's get it sorted out at the project level and apply consistently. Psalm at level 1 should be able to report (and maybe fix) some of such issues.
See #4503.
PostgreSQLSchemaManager::getExistingSchemaSearchPaths()
and::determineExistingSchemaSearchPaths()
have been marked internal and will be made protected in4.0.0
. They are only used by the schema manager itself and are not part of the API.AbstractSchemaManager::dropSchema()
has been added to implement the test properly.AbstractSchemaManager::listSchemaNames()
has been added as a replacement forAbstractSchemaManager::listNamespaceNames()
andPostgreSQLSchemaManager::getSchemaNames()
.Reasoning behind the naming changes:
The "namespace" term is internal to PostgreSQL and isn't part of the ANSI SQL vocabulary:
Schemas are supported by most if not all platforms supported by the DBAL.
Reasoning behind the design changes:
The new
AbstractSchemaManager::listSchemaNames()
method have been implemented directly in the schema manager instead of using thegetListSchemataSQL()
→getPortableSchemaList()
→getPortableSchemaDefinition()
approach. This approach has the following flaws:getListSchemataSQL(): string
would be part of the abstract API, it could be used only within a given platform or even its version, so it's not really part of the abstraction. Also, such methods are untestable unless tested as part of the schema manager.getPortableSchemaDefinition()
would expect alist<string,mixed>
and return alist<string>
but again, it couldn't accept a row set from another platform. Furthermore, neither the API nor default the default implementation of such methods make any sense:dbal/src/Schema/AbstractSchemaManager.php
Lines 710 to 718 in f18aee0
AbstractSchemaManager::dropSchema()
has been implemented using the implementation fromAbstractPlatform
in order to be able to reuse it go generate migrations.