-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Postgres SERIAL is not a post-insert identifier generation strategy #1184
Conversation
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DDC-3389 We use Jira to track the state of pull requests and the versions they got |
@@ -71,7 +71,7 @@ public static function entityMissingForeignAssignedId($entity, $relatedEntity) | |||
"Entity of type " . get_class($entity) . " has identity through a foreign entity " . get_class($relatedEntity) . ", " . | |||
"however this entity has no identity itself. You have to call EntityManager#persist() on the related entity " . | |||
"and make sure that an identifier was generated before trying to persist '" . get_class($entity) . "'. In case " . | |||
"of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call " . | |||
"of Post Insert ID Generation (such as MySQL Auto-Increment) this means you have to call " . |
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.
Serial is actually one, since we insert the record and read the last insert id for the current session. The fact that it is backed by a sequence is a different story.
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.
we insert the record and read the last insert id for the current session.
This is not true, the persist()
call will call the DB and get the next available ID, later an insert will be performed using the obtained ID
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.
That's when using a sequence explicitly. SERIAL
is using a sequence implicitly. I'm looking at Doctrine\ORM\Id\IdentityGenerator
When using SERIAL
fields, then this generator is being used, whereas using a sequence explicitly causes the Doctrine\ORM\Id\SequenceGenerator
to be used.
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.
Blah, nvm, my fault, found that Doctrine\ORM\Mapping\ClassMetadataFactory
is true
for Doctrine\DBAL\Platforms\PostgreSqlPlatform
, so the sequence name is extracted in any case when using SERIAL
columns (and ClassMetadata::GENERATOR_TYPE_AUTO
), and a sequence generator is used.
Merging.
Postgres SERIAL is not a post-insert identifier generation strategy
I think that #605 can be closed... |
No description provided.