DDC-3215: wrong quotation #3983

Closed
opened 2026-01-22 14:32:53 +01:00 by admin · 9 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 16, 2014).

Originally assigned to: @ostrolucky on GitHub.

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
     */
Originally created by @doctrinebot on GitHub (Jul 16, 2014). Originally assigned to: @ostrolucky on GitHub. 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 */ ```
admin added the Bug label 2026-01-22 14:32:53 +01:00
admin closed this issue 2026-01-22 14:32:54 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jul 16, 2014):

Comment created by @ocramius:

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

@doctrinebot commented on GitHub (Jul 16, 2014): Comment created by @ocramius: Could you please convert this to a failing test case? Doctrine doesn't quote integers as strings by default.
Author
Owner

@doctrinebot commented on GitHub (Jul 16, 2014):

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 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?

@doctrinebot commented on GitHub (Jul 16, 2014): 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 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?
Author
Owner

@doctrinebot commented on GitHub (Jul 16, 2014):

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 commented on GitHub (Jul 16, 2014): 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?
Author
Owner

@doctrinebot commented on GitHub (Jul 16, 2014):

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 commented on GitHub (Jul 16, 2014): 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
Author
Owner

@doctrinebot commented on GitHub (Jul 16, 2014):

Comment created by @ocramius:

Can you var_dump the Base\Entities\Messe instance?

@doctrinebot commented on GitHub (Jul 16, 2014): Comment created by @ocramius: Can you `var_dump` the `Base\Entities\Messe` instance?
Author
Owner

@doctrinebot commented on GitHub (Jul 16, 2014):

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 commented on GitHub (Jul 16, 2014): 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:00<ins>02: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</ins>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}
Author
Owner

@doctrinebot commented on GitHub (Jul 17, 2014):

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 commented on GitHub (Jul 17, 2014): 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
Author
Owner

@doctrinebot commented on GitHub (Jan 20, 2015):

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: 445798ed46) to the BasicEntityPersister seemed fixed it.

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

@doctrinebot commented on GitHub (Jan 20, 2015): 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: 445798ed46291f2639b3657142bd2f934d1be8a6) to the BasicEntityPersister seemed fixed it. @revrev: Could you please retest your example? This bug might be fixed. Thx.
Author
Owner

@ostrolucky commented on GitHub (Aug 7, 2018):

Apparently resolved in 2.5.x-dev

@ostrolucky commented on GitHub (Aug 7, 2018): Apparently resolved in 2.5.x-dev
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3983