mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3377: DateTime columns cannot be used with @Id #4174
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 @doctrinebot on GitHub (Nov 6, 2014).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user cverges-ch:
DateTimeIdTest.php:
test.php:
Output:
I was able to debug this down to where the implode() call in Doctrine\ORM\UnitOfWork::addToIdentityMap() is what is triggering this problem. It attempts to convert all contained entities in the Doctrine\ORM\UnitOfWork::entityIdentifiers array to strings. For a DateTime object, the DateTime::format() function should be used instead of relying on **toString().
@doctrinebot commented on GitHub (Nov 6, 2014):
@doctrinebot commented on GitHub (Nov 6, 2014):
Comment created by cverges-ch:
There is a portable workaround where you create a string-based shadow key that gets updated by Doctrine events:
DateTimeIdTest.php:
@doctrinebot commented on GitHub (Nov 7, 2014):
Issue was closed with resolution "Duplicate"
@peter-gribanov commented on GitHub (Jan 12, 2018):
Will this bug fix?
@Ocramius commented on GitHub (Jan 12, 2018):
@peter-gribanov I already marked this as
duplicate@peter-gribanov commented on GitHub (Jan 12, 2018):
@Ocramius Thanks. I noticed, but where is the original issue? Is it only in your Jira?
@Ocramius commented on GitHub (Jan 12, 2018):
@peter-gribanov all issues were copied over and auto-closed: you can search for them by the identifier (for example
DDC-123456) in this repo@peter-gribanov commented on GitHub (Jan 12, 2018):
This issue related:
@Ocramius All tasks that i can see is are already closed, but the bug is not resolved. And yet, where can i find out and monitor the status of this bug?
@drupol commented on GitHub (Dec 7, 2020):
I'm also looking for a solution.
@beberlei commented on GitHub (Dec 7, 2020):
@drupol You could look into using Chronos for Date intead of native date types. They have a __toString and that should make this work: https://packagist.org/packages/warhuhn/chronos-doctrine
@drupol commented on GitHub (Dec 7, 2020):
Thanks @beberlei, I will give it a try again.
@drupol commented on GitHub (Dec 7, 2020):
Dear @beberlei , I tried here: https://github.com/drupol/doctrine-date-as-id/pull/2 but apparently, it's the same issue.
@beberlei commented on GitHub (Dec 7, 2020):
Please read the error csrefully, your code still has a DateTime object there you need a Chronos instance