Skip to content

Commit 68d7156

Browse files
committed
make sure we never do case sensitive string comparison when parsing sql2. fix #10
1 parent 7ae28f9 commit 68d7156

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/PHPCR/Util/QOM/Sql2ToQomQueryConverter.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected function parseSelector()
139139
{
140140
$token = $this->fetchTokenWithoutBrackets();
141141

142-
if (strtoupper($this->scanner->lookupNextToken()) === 'AS') {
142+
if ($this->scanner->tokenIs($this->scanner->lookupNextToken(), 'AS')) {
143143
$this->scanner->fetchNextToken(); // Consume the AS
144144
$selectorName = $this->parseName();
145145

@@ -414,7 +414,7 @@ protected function parseComparison()
414414
/**
415415
* 6.7.17 Operator
416416
*
417-
* @return \PHPCR\Query\QOM\OperatorInterface
417+
* @return string a constant from QueryObjectModelConstantsInterface
418418
*/
419419
protected function parseOperator()
420420
{
@@ -453,7 +453,7 @@ protected function parsePropertyExistence()
453453
if ($this->scanner->tokenIs($token, 'NULL')) {
454454
$this->scanner->fetchNextToken();
455455

456-
return $this->factory->not($this->factory->propertyExistence($prop, $selector));
456+
return $this->factory->notConstraint($this->factory->propertyExistence($prop, $selector));
457457
}
458458

459459
$this->scanner->expectTokens(array('NOT', 'NULL'));
@@ -731,18 +731,17 @@ protected function parseOrderings()
731731
protected function parseOrdering()
732732
{
733733
$operand = $this->parseDynamicOperand();
734-
$token = strtoupper($this->scanner->lookupNextToken());
734+
$token = $this->scanner->lookupNextToken();
735735

736-
if ($token === 'DESC') {
736+
if ($this->scanner->tokenIs($token, 'DESC')) {
737737
$this->scanner->expectToken('DESC');
738738

739739
return $this->factory->descending($operand);
740740
}
741741

742-
if ($token === 'ASC' || $token === ',' || $token === '') {
743-
if ($token === 'ASC') {
744-
// Consume ASC
745-
$this->scanner->fetchNextToken();
742+
if ($this->scanner->tokenIs($token, 'ASC') || ',' === $token || '' === $token) {
743+
if ($this->scanner->tokenIs($token, 'ASC')) {
744+
$this->scanner->expectToken('ASC');
746745
}
747746

748747
return $this->factory->ascending($operand);
@@ -837,7 +836,7 @@ protected function parseColumn()
837836
list($propertyName, $selectorName) = $this->parseIdentifier();
838837

839838
// AS name
840-
if (strtoupper($this->scanner->lookupNextToken()) === 'AS') {
839+
if ($this->scanner->tokenIs($this->scanner->lookupNextToken(), 'AS')) {
841840
$this->scanner->fetchNextToken();
842841
$columnName = $this->scanner->fetchNextToken();
843842
} else {

0 commit comments

Comments
 (0)