Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: DQL, ORM
    • Security Level: All
    • Labels:

      Description

      when doctrine build query´s, for example when you doing

      $entitity->getTest()->clear();
      

      following queries are generated (test_id is integer in mysql):

      DELETE FROM test WHERE test_id = '6'
      

      Is this right?
      For me the right query would be:

      DELETE FROM test WHERE test_id = 6
      

      as in http://dev.mysql.com/doc/refman/5.5/en/type-conversion.html
      6 will be converted to float, this can be an issue, or?

      Comparisons that use floating-point numbers (or values that are converted to floating-point numbers) are approximate because such numbers are inexact. This might lead to results that appear inconsistent:

      mysql> SELECT '18015376320243458' = 18015376320243458;
              -> 1
      mysql> SELECT '18015376320243459' = 18015376320243459;
              -> 0
      

      this also happens in dql sometimes, why doctrine does this not automatic right due to description in the entities?

           /**
           * @ORM\Id @ORM\Column(type="integer")
           * @ORM\GeneratedValue
           */
      

        Activity

        Hide
        Marco Pivetta added a comment -

        Could you please convert this to a failing test case? Doctrine doesn't quote integers as strings by default.

        Show
        Marco Pivetta added a comment - Could you please convert this to a failing test case? Doctrine doesn't quote integers as strings by default.
        Hide
        revrev added a comment - - edited

        i try to describe what i have done

        i have an Entity with:

            /**
             * @ORM\ManyToMany(targetEntity="Messen", inversedBy="vertrag_messen")
             * @ORM\JoinTable(name="vertrag_messen")
             **/
            private $vertrag_messen;
        
            public function __construct()
            {
                $this->vertrag_messen = new \Doctrine\Common\Collections\ArrayCollection();
            }
        
            public function getMessen()
            {
                return $this->vertrag_messen;
            }
        

        when i now clear the Data

        $entitity->getMessen()->clear();
        

        following query is created
        DELETE FROM vertrag_messen where messe_id = '6'

        Should here not set the value 6 as integer (param_int) (DELETE FROM test vertrag_messen where messe_id = 6) that mysql doesn´t have to cast the value? (http://dev.mysql.com/doc/refman/5.5/en/type-conversion.html) or is this not an problem?

        Show
        revrev added a comment - - edited i try to describe what i have done i have an Entity with: /** * @ORM\ManyToMany(targetEntity= "Messen" , inversedBy= "vertrag_messen" ) * @ORM\JoinTable(name= "vertrag_messen" ) **/ private $vertrag_messen; public function __construct() { $ this ->vertrag_messen = new \Doctrine\Common\Collections\ArrayCollection(); } public function getMessen() { return $ this ->vertrag_messen; } when i now clear the Data $entitity->getMessen()->clear(); following query is created DELETE FROM vertrag_messen where messe_id = '6' Should here not set the value 6 as integer (param_int) ( DELETE FROM test vertrag_messen where messe_id = 6 ) that mysql doesn´t have to cast the value? ( http://dev.mysql.com/doc/refman/5.5/en/type-conversion.html ) or is this not an problem?
        Hide
        Marco Pivetta added a comment -

        is messe_id in your entity an integer or a string at the moment in time when that query is being executed?

        Show
        Marco Pivetta added a comment - is messe_id in your entity an integer or a string at the moment in time when that query is being executed?
        Hide
        revrev added a comment - - edited

        the value comes automatic
        $entitity = $em->getRepository('Base\Entities\Vertrag')>find(intval($data["id"]));

        i don´t set messe_id here

        Show
        revrev added a comment - - edited the value comes automatic $entitity = $em->getRepository('Base\Entities\Vertrag')>find(intval($data ["id"] )); i don´t set messe_id here
        Hide
        Marco Pivetta added a comment -

        Can you var_dump the Base\Entities\Messe instance?

        Show
        Marco Pivetta added a comment - Can you var_dump the Base\Entities\Messe instance?
        Hide
        revrev added a comment - - edited

        object(stdClass)#1014 (64) {
        ["__CLASS__"]=>
        string(24) "Base\Entities\Vertrag"
        ["id"]=>
        int(6)
        [„vertrag_messen"]=>
        array(1)

        Unknown macro: { [0]=> string(20) "BaseEntitiesMessen" }


        ["erstellungsdatum"]=>
        object(stdClass)#1210 (3)

        Unknown macro: { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2013-09-28T00}

        ["zeitraumvon"]=>
        NULL
        ["zeitraumbis"]=>
        NULL
        ["jahr"]=>
        int(2014)
        ["created"]=>
        object(stdClass)#1178 (3)

        Unknown macro: { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2013-09-28T19}

        ["updated"]=>
        object(stdClass)#1177 (3)

        Unknown macro: { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2014-07-16T17}

        ["uuid"]=>
        string(36) "52470c58-4288-45eb-b75f-0c41c0a81437"
        }

        Show
        revrev added a comment - - edited object(stdClass)#1014 (64) { ["__CLASS__"] => string(24) "Base\Entities\Vertrag" ["id"] => int(6) [„vertrag_messen"] => array(1) Unknown macro: { [0]=> string(20) "BaseEntitiesMessen" } ["erstellungsdatum"] => object(stdClass)#1210 (3) Unknown macro: { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2013-09-28T00} ["zeitraumvon"] => NULL ["zeitraumbis"] => NULL ["jahr"] => int(2014) ["created"] => object(stdClass)#1178 (3) Unknown macro: { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2013-09-28T19} ["updated"] => object(stdClass)#1177 (3) Unknown macro: { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2014-07-16T17} ["uuid"] => string(36) "52470c58-4288-45eb-b75f-0c41c0a81437" }
        Hide
        Marco Pivetta added a comment -

        yeah, integer identifier there.
        Could you verify if the problem also comes up with current master? I think this issue is related with another one that was fixed some months ago in 2.5.x-dev

        Show
        Marco Pivetta added a comment - yeah, integer identifier there. Could you verify if the problem also comes up with current master? I think this issue is related with another one that was fixed some months ago in 2.5.x-dev

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            revrev
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: