[DDC-1209] DateTime (and other custom object types) cannot be used in primary key (singular or composite) Created: 15/Jun/11 Updated: 14/Sep/12 Resolved: 16/Jun/11
|Project:||Doctrine 2 - ORM|
|Affects Version/s:||Git Master|
|Reporter:||Michael Ridgway||Assignee:||Guilherme Blanco|
This bug was encountered using a DateTime type as an @Id, but it appears that it will affect any type of custom data type if it is an object.
Doctrine\ORM\Id\AssignedGenerator checks to see if the key is an object. If so it does a look up in the identity map to find the object, but in the case of DateTime it will not find it and throws an exception. It is appears this is the case for both singular and composite keys as shown in the attached test.
Test case forthcoming.
|Comment by Michael Ridgway [ 15/Jun/11 ]|
|Comment by Michael Ridgway [ 16/Jun/11 ]|
I posted a fix and it was merged this morning by Guilherme: https://github.com/doctrine/doctrine2/pull/74
|Comment by Jonathan Ingram [ 11/Sep/12 ]|
I am wondering if this fix is working correctly or has regressed?
I have a YAML file as follows:
So the "dateExecuted" field is used to compose an artificial primary key since the table has no PK.
The error is:
In my composer.json, the relevant versions of Doctrine are:
Is this a bug or am I misusing this?
|Comment by Christophe Coevoet [ 13/Sep/12 ]|
this has never been supported. Doctrine 2 has always required id fields to be castable as string, which is not the case of a DateTime object
|Comment by Jonathan Ingram [ 14/Sep/12 ]|
But didn't the PR https://github.com/doctrine/doctrine2/pull/74 get merged in https://github.com/doctrine/doctrine2/commit/98bc3c4e402731fae8716e99c7c19d5e0ff7b60a ? And you can see the use of @Id in the test cases, e.g. https://github.com/doctrine/doctrine2/commit/98bc3c4e402731fae8716e99c7c19d5e0ff7b60a#L2R78 ?