Skip to content

Commit 7c29078

Browse files
committed
Treat '0' as a legitimate trim char
Because of a loose comparison, it was not.
1 parent 401a0c4 commit 7c29078

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Query/AST/Functions/TrimFunction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function parse(Parser $parser)
7474
$this->trimChar = $lexer->token->value;
7575
}
7676

77-
if ($this->leading || $this->trailing || $this->both || $this->trimChar) {
77+
if ($this->leading || $this->trailing || $this->both || ($this->trimChar !== false)) {
7878
$parser->match(Lexer::T_FROM);
7979
}
8080

tests/Tests/ORM/Query/LanguageRecognitionTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ public function testFunctionalExpressionsSupportedInWherePart(): void
172172
$this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'");
173173
}
174174

175+
public function testTrimFalsyString(): void
176+
{
177+
$this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM('0' FROM u.name) = 'someone'");
178+
}
179+
175180
public function testArithmeticExpressionsSupportedInWherePart(): void
176181
{
177182
$this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000');

0 commit comments

Comments
 (0)