Jira issue originally created by user stof:
The current implementation concatenates the fields used in a primary key. This does not work for datetime fields as a DateTime object is not castable as string. It would be useful to allow them to be used in primary keys too.
Comment created by @beberlei:
A "general" fix would be much to expensive in php userland. What you can do is implement your own datetime type for this purpose that creates a DateTime derivate that implements **toString()
Issue was closed with resolution "Invalid"
Comment created by seldaek:
Igor worked on a patch email@example.com...[DDC-1061](http://www.doctrine-project.org/jira/browse/DDC-1061) - not sure what the perf impact is, but it sure would be nice to support this, or at least to throw an exception or something more obvious than how it currently behaves.
There is also #232
Comment created by stof:
The work done by Igor is flawed: the object will be hydrated several times because different DB call will return different DateTime instances, thus leading to a different hash in the UoW
A related Github Pull-Request [GH-232] was
Comment created by darkangel:
Please consider reopening this, it seems a bit crazy that you can't use a date or datetime field in a composite PK.
Does checking if the field is an instance of DateTime and if so calling getTimestamp() or format('c') really affect the performance significantly?
Comment created by @ocramius:
It does not only affect performance, it is also an opinionated approach.
If you need to use a datetime within a PK, simply provide an implementation of DateTime that includes **toString