[DDC-1998] Problem when deleting with EntityManager->remove($entity) Created: 28/Aug/12  Updated: 15/Feb/14  Resolved: 01/May/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.2.3
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Minor
Reporter: victor Velkov Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Attachments: File DDC1998Test.php     File DDC1998Test1.php     File EwtTimestamp.php     File ProductTemplate.php    
Issue Links:
is duplicated by DDC-2176 Illegal offset type in isset or empty... Resolved


The problem is when using EntityMamager->remove($entity). The Sql query generated doesn't convert the values of the ids according to the field type that is used in doc block annotation. After investigating I found that in Doctrine\DBAL\Connection the function delete doesn't support to receive as param the types of the ids to be given to the executeUpdate function which is called in it and supports them. (The types need to be provided from the persisters from which the delete is called).

I hope it make sense to you. I got that problem because I am using custom time stamp column type as id. And it converts the value of the field to time stamp string, which if not converted to the proper sql value is not recognised and the delete doesn't go trough.

As far as I can see it is something that was missed and hope it will be fixed soon.

If you have any questions please ask.
Also on request I can provide example code and the fix I have done for myself.

Comment by Fabio B. Silva [ 29/Aug/12 ]

Hi Victor

Could you attach/paste your custom type and entity please ?

Comment by victor Velkov [ 30/Aug/12 ]

Ok I have attached them. The EwtTimestamp is the custom type.

Comment by Marco Pivetta [ 17/Sep/12 ]

victor Velkov do you have a failing test case for this one?

Comment by victor Velkov [ 17/Sep/12 ]

Nope sorry haven't done any test cases for this one

Comment by Fabio B. Silva [ 23/Sep/12 ]

Hi Victor,

I can't reproduce, could you change the added test case and try to make it fails ?


Comment by victor Velkov [ 26/Sep/12 ]

Sure will do it as soon as I can. Sorry I didn't answer sooner just was in a holiday

Comment by Fabio B. Silva [ 02/Oct/12 ]

Thanks Victor

Please let me know when you change the test

Comment by victor Velkov [ 02/Oct/12 ]

Sorry for the delay i have attached the test case (DDC1998Test1.php).

Comment by Fabio B. Silva [ 10/Oct/12 ]

Hi Victor,

Sorry for the delay to answer

I think that we can't fix it,
Your type requires sql conversion to work, and doctrine does not support @Id fields with sql conversion.

Comment by victor Velkov [ 11/Oct/12 ]

Really as far as i can see in the code you do convert them when you are executing an update. And the fix that i did for my self is to add 3rd parameter to the function delete in Doctrine\DBAL\Connection and then every where where it is called in the code which is in 2 places Doctrine\ORM\Persisters\BasicEntityPersister and Doctrine\ORM\JoinedSubclassPersister to give that parameter with the types. And as far as i can see you do that for the updates. After that in Connection delete you call the executeUpdate which supports the type and you just have to pass it along. And that is it.

Comment by Marco Pivetta [ 23/Jan/13 ]

Reducing priority. It is an edge case, and we already don't officially support custom object types as identifiers.

Comment by Benjamin Eberlei [ 01/May/13 ]

We should be able to support this I think, i don't see a reason it shouldnt work

Comment by Benjamin Eberlei [ 01/May/13 ]

Will be fixed in 2.4

Generated at Fri Oct 09 12:01:21 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.