orm
orm copied to clipboard
Implement a ReturningIdGenerator that leverage `INSERT INTO .... RETURNING id`
Feature Request
| Q | A |
|---|---|
| New Feature | yes |
| RFC | yes/no |
| BC Break | no |
Summary
Add in AbstractIdGenerator a method
isInsertReturningGenerator()
which will return false by default
Note: a "cleaner" way would have been to replace isPostInsertGenerator by a "getGeneratorKind" that return an enum pre/during/post but that would break BC
create a ReturningIdGenerator (I'm bad at naming) that will have function isInsertReturningGenerator { return true;}
so that after in BasicEntityPersister can be modified to have getInsertSQL to add a RETURNING %idColumn
and then in executeInserts we can do
$generatedId $stmt->executeQuery()->fetchOne;
that will divide by two the number of request required when doing inserts (as you will not need the pre or post insert request to get the id )
especially as this keyword is supported by several vendors (potgresql , mariadb , oracle among others ) and it will be opt-in for the user.
If that seems like a good idea I may work on a PR