Skip to content

Commit

Permalink
Merge branch '5.11.x'
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
  • Loading branch information
MauricioFauth committed Oct 25, 2024
2 parents 9d4796d + 4652d80 commit f4b2a20
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Parsers/Conditions.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ public static function parse(Parser $parser, TokensList $list, array $options =
}

// Conditions are delimited by logical operators.
if (in_array($token->value, self::DELIMITERS, true)) {
if (
($token->type === TokenType::Keyword || $token->type === TokenType::Operator)
&& in_array($token->value, self::DELIMITERS, true)
) {
if ($betweenBefore && ($token->value === 'AND')) {
// The syntax of keyword `BETWEEN` is hard-coded.
$betweenBefore = false;
Expand Down
6 changes: 6 additions & 0 deletions tests/Components/ConditionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ public function testParseBetween(): void
$this->assertEquals('OR', $component[1]->expr);
$this->assertEquals('(id BETWEEN 30 AND 40)', $component[2]->expr);
}

public function testParseAnd(): void
{
$component = Conditions::parse(new Parser(), $this->getTokensList("`col` LIKE 'AND'"));
$this->assertEquals("`col` LIKE 'AND'", Conditions::buildAll($component));
}
}

0 comments on commit f4b2a20

Please sign in to comment.