mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Custom type ignored by identity generator #5026
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bharley on GitHub (Feb 27, 2016).
Originally assigned to: @Ocramius on GitHub.
I have a custom type which extends the
IntegerType. It encodes the integer on the way out of the database, and decodes it on the way in with the use ofconvertToPHPValue/convertToDatabaseValue. I tried using it like so:The problem with this implementation is that the generated value returned from the database after a
persist/flushoperation is the integer stored in the database; not the value as it would be had it passed through theconvertToPHPValuemethod of my custom type.@OJezu commented on GitHub (Apr 26, 2016):
I would like to add, that even if you try to create your own generator that will convert the value, well too bad, because doctrine is hardcoded to add autoincrement only when generated value strategy is identity. If you try to roll your own, its impossible to have autoincrement on your columns.
@mantiz commented on GitHub (Jul 13, 2016):
I encountered the same problem today. A small debugging session pointed me to
2b47670831/lib/Doctrine/ORM/UnitOfWork.php (L1016)where the value of the id generator gets directly assigned.I made a few quick changes directly below the linked line and it seems to work well. The changes are:
The
Typesnamespace, of course, was used byuse Doctrine\DBAL\Types.I'm not sure if this has any relevant performance (or other) issues.
If someone could confirm that these changes are reasonable, I would be happy to submit a pull request within the next days. Just let me know. 😉
@Ocramius commented on GitHub (Nov 27, 2016):
This was handled in #6152