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

          victor Velkov created issue -
          Hide
          Fabio B. Silva added a comment -

          Hi Victor

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

          Show
          Fabio B. Silva added a comment - Hi Victor Could you attach/paste your custom type and entity please ?
          victor Velkov made changes -
          Field Original Value New Value
          Attachment EwtTimestamp.php [ 11315 ]
          Attachment ProductTemplate.php [ 11316 ]
          Hide
          victor Velkov added a comment -

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

          Show
          victor Velkov added a comment - Ok I have attached them. The EwtTimestamp is the custom type.
          Hide
          Marco Pivetta added a comment -

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

          Show
          Marco Pivetta added a comment - victor Velkov do you have a failing test case for this one?
          Hide
          victor Velkov added a comment -

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

          Show
          victor Velkov added a comment - Nope sorry haven't done any test cases for this one
          Hide
          Fabio B. Silva added a comment - - edited

          Hi Victor,

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

          Thanks

          Show
          Fabio B. Silva added a comment - - edited Hi Victor, I can't reproduce, could you change the added test case and try to make it fails ? Thanks
          Fabio B. Silva made changes -
          Attachment DDC1998Test.php [ 11325 ]
          Fabio B. Silva made changes -
          Status Open [ 1 ] Awaiting Feedback [ 10000 ]
          Hide
          victor Velkov added a comment -

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

          Show
          victor Velkov added a comment - Sure will do it as soon as I can. Sorry I didn't answer sooner just was in a holiday
          Hide
          Fabio B. Silva added a comment -

          Thanks Victor

          Please let me know when you change the test

          Show
          Fabio B. Silva added a comment - Thanks Victor Please let me know when you change the test
          Hide
          victor Velkov added a comment -

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

          Show
          victor Velkov added a comment - Sorry for the delay i have attached the test case (DDC1998Test1.php).
          victor Velkov made changes -
          Attachment DDC1998Test1.php [ 11335 ]
          victor Velkov made changes -
          Attachment DDC1998Test1.php [ 11335 ]
          victor Velkov made changes -
          Attachment DDC1998Test1.php [ 11336 ]
          made changes -
          Status Awaiting Feedback [ 10000 ] In Progress [ 3 ]
          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.
          Andrea Barani made changes -
          Status In Progress [ 3 ] Awaiting Feedback [ 10000 ]
          Andrea Barani made changes -
          Status Awaiting Feedback [ 10000 ] In Progress [ 3 ]
          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.
          Marco Pivetta made changes -
          Priority Blocker [ 1 ] Minor [ 4 ]
          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
          Benjamin Eberlei made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Fix Version/s 2.4 [ 10321 ]
          Resolution Fixed [ 1 ]
          Marco Pivetta made changes -
          Link This issue is duplicated by DDC-2176 [ DDC-2176 ]

          This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

          • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-1998, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

            People

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

              Dates

              • Created:
                Updated:
                Resolved: