Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1998

Problem when deleting with EntityManager->remove($entity)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.3
    • Fix Version/s: 2.4
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      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.

      1. DDC1998Test.php
        3 kB
        Fabio B. Silva
      2. DDC1998Test1.php
        3 kB
        victor Velkov
      3. EwtTimestamp.php
        2 kB
        victor Velkov
      4. ProductTemplate.php
        0.8 kB
        victor Velkov

        Issue Links

          Activity

          Hide
          Fabio B. Silva added a comment -

          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.

          Show
          Fabio B. Silva added a comment - 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.
          Hide
          victor Velkov added a comment -

          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.

          Show
          victor Velkov added a comment - 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.
          Hide
          Marco Pivetta added a comment -

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

          Show
          Marco Pivetta added a comment - Reducing priority. It is an edge case, and we already don't officially support custom object types as identifiers.
          Hide
          Benjamin Eberlei added a comment -

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

          Show
          Benjamin Eberlei added a comment - We should be able to support this I think, i don't see a reason it shouldnt work
          Hide
          Benjamin Eberlei added a comment -

          Will be fixed in 2.4

          Show
          Benjamin Eberlei added a comment - Will be fixed in 2.4

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              victor Velkov
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: