Skip to content

Commit

Permalink
Merge pull request #11270 from greg0ire/fix-trim-bug
Browse files Browse the repository at this point in the history
Treat '0' as a legitimate trim char
  • Loading branch information
greg0ire authored Feb 18, 2024
2 parents e4769d3 + cf408ad commit efb6ceb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
18 changes: 0 additions & 18 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1543,15 +1543,6 @@
</PossiblyInvalidPropertyAssignmentValue>
</file>
<file src="src/Query/AST/Functions/DateAddFunction.php">
<ArgumentTypeCoercion>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
</ArgumentTypeCoercion>
<PossiblyInvalidPropertyAssignmentValue>
<code><![CDATA[$parser->ArithmeticPrimary()]]></code>
<code><![CDATA[$parser->ArithmeticPrimary()]]></code>
Expand All @@ -1572,15 +1563,6 @@
</PossiblyInvalidPropertyAssignmentValue>
</file>
<file src="src/Query/AST/Functions/DateSubFunction.php">
<ArgumentTypeCoercion>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
<code><![CDATA[$this->intervalExpression->dispatch($sqlWalker)]]></code>
</ArgumentTypeCoercion>
<UndefinedPropertyFetch>
<code><![CDATA[$this->unit->value]]></code>
</UndefinedPropertyFetch>
Expand Down
2 changes: 1 addition & 1 deletion src/Query/AST/Functions/TrimFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function parse(Parser $parser)
$this->trimChar = $lexer->token->value;
}

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

Expand Down
5 changes: 5 additions & 0 deletions tests/Tests/ORM/Query/LanguageRecognitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ public function testFunctionalExpressionsSupportedInWherePart(): void
$this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'");
}

public function testTrimFalsyString(): void
{
$this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM('0' FROM u.name) = 'someone'");
}

public function testArithmeticExpressionsSupportedInWherePart(): void
{
$this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000');
Expand Down

0 comments on commit efb6ceb

Please sign in to comment.