Skip to content

Loading…

DDC-3215: wrong quotation #4001

Open
doctrinebot opened this Issue · 8 comments

2 participants

@doctrinebot

Jira issue originally created by user revrev:

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
     */
@doctrinebot

Comment created by @ocramius:

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

@doctrinebot

Comment created by revrev:

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 vertragmessen where messeid = '6'

Should here not set the value 6 as integer (paramint) (`DELETE FROM test vertrag_messen where messeid = 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?

@doctrinebot

Comment created by @ocramius:

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

@doctrinebot

Comment created by revrev:

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

i don´t set messe_id here

@doctrinebot

Comment created by @ocramius:

Can you var_dump the Base\Entities\Messe instance?

@doctrinebot

Comment created by revrev:

{quote}
object(stdClass)#1014 (64) {
["CLASS"]=>
string(24) "Base\Entities\Vertrag"
["id"]=>
int(6)

[„vertrag_messen"]=>
array(1) {
[0]=>
string(20) "Base\Entities\Messen"
}

["erstellungsdatum"]=>
object(stdClass)#1210 (3) {
["CLASS"]=>
string(8) "DateTime"
["date"]=>
string(25) "2013-09-28T00:00:0002:00"
["timezone"]=>
string(13) "Europe/Berlin"
}
["zeitraumvon"]=>
NULL
["zeitraumbis"]=>
NULL
["jahr"]=>
int(2014)
["created"]=>
object(stdClass)#1178 (3) {
["CLASS"]=>
string(8) "DateTime"
["date"]=>
string(25) "2013-09-28T19:05:28
02:00"
["timezone"]=>
string(13) "Europe/Berlin"
}
["updated"]=>
object(stdClass)#1177 (3) {
["CLASS"]=>
string(8) "DateTime"
["date"]=>
string(25) "2014-07-16T17:18:10+02:00"
["timezone"]=>
string(13) "Europe/Berlin"
}
["uuid"]=>
string(36) "52470c58-4288-45eb-b75f-0c41c0a81437"

}
{quote}

@doctrinebot

Comment created by @ocramius:

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

@doctrinebot

Comment created by thegh0st:

@Marco Pivetta:

I was affected by exact the same issue. Even when running git master at the beginning of last week, it was still broken.
Today I retestet. Luckily your latest commits (from beginning with: 445798e) to the BasicEntityPersister seemed fixed it.

@revrev:
Could you please retest your example? This bug might be fixed. Thx.

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.