docs: generation strategies: differences between DBAL 3 and 4 #12148
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I'm currently updating Doctrine DBAL from version 3 to 4 on an app that uses Doctrine generated ID columns (with no strategy defined, thus using
AUTOif I'm not mistaken) with PostgreSQL 17.I suspect that the generation strategies' documentation for PostgreSQL is outdated or inaccurate, due to changes introduced in / for Doctrine DBAL 4.
Here's a more detailed report / explanation:
I initially encountered database errors about PostgreSQL's
SEQUENCE, and tried tinkering with the strategy, to no avail.I then stumbled upon the following documentation: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/how-to/postgresql-identity-migration.rst
Still, something about the generation strategies' documentation confused me: the documentation claims that no matter Doctrine DBAL's version, the default (
AUTO) strategy on PostgreSQL isSEQUENCE.When tested on my app, either of these 2 lines produce the same database migrations:
but the
SEQUENCEstrategy just seems to remove theDEFAULT:This behavior suggested that the default strategy on PostgreSQL would be
IDENTITYand notSEQUENCE.After digging into the code, it seems to be the case:
NON_IDENTITY_DEFAULT_STRATEGY:orm/src/Mapping/ClassMetadataFactory.php
Lines 63 to 65 in 21e9fcb
orm/src/Mapping/ClassMetadataFactory.php
Lines 631 to 634 in 21e9fcb
IDENTITY:orm/src/Mapping/ClassMetadataFactory.php
Line 666 in 21e9fcb
PostgreSQLPlatformthen outputsGENERATED BY DEFAULT AS IDENTITY: https://github.com/doctrine/dbal/blob/1432ec68513bb1788d9ed4e7ace4f12f6595fb9c/src/Platforms/PostgreSQLPlatform.php#L276Thank you for reviewing my PR, tell me if there is anything wrong / that can be improved in it 👍
Thank you for all the work you did on Doctrine!
PS : Do these documentation changes need to be backported all the way back to ORM 3.0? The initial commit that introduced this difference seems to date back to ORM 3.0 RC 1: bdc039f