Skip to content

Commit 8b20282

Browse files
committed
Merge pull request #119 from phpcr/fix_cast_parsing
fix previous refactoring of parseLiteral() to parseListeralValue()
2 parents 717e75e + 72fc31f commit 8b20282

File tree

1 file changed

+2
-49
lines changed

1 file changed

+2
-49
lines changed

src/PHPCR/Util/QOM/Sql2ToQomQueryConverter.php

+2-49
Original file line numberDiff line numberDiff line change
@@ -772,15 +772,15 @@ protected function parseCastLiteral($token)
772772
throw new InvalidQueryException("Syntax error: attempting to cast string '$token' to type '$type'");
773773
}
774774

775-
return $this->factory->literal($token);
775+
return $token;
776776
}
777777
}
778778

779779
/**
780780
* 6.7.34 Literal
781781
* Parse an SQL2 literal value
782782
*
783-
* @return LiteralInterface
783+
* @return mixed
784784
*/
785785
protected function parseLiteralValue()
786786
{
@@ -829,53 +829,6 @@ protected function parseLiteralValue()
829829
return $token;
830830
}
831831

832-
/**
833-
* 6.7.34 Fulltext Literal
834-
* Parse an SQL2 literal value
835-
*
836-
* @return LiteralInterface
837-
*/
838-
protected function parseFulltextLiteral()
839-
{
840-
$token = $this->scanner->fetchNextToken();
841-
if ($this->scanner->tokenIs($token, 'CAST')) {
842-
return $this->parseCastLiteral($token);
843-
}
844-
845-
$quoteString = false;
846-
if (substr($token, 0, 1) === '\'') {
847-
$quoteString = "'";
848-
} elseif (substr($token, 0, 1) === '"') {
849-
$quoteString = '"';
850-
}
851-
852-
if ($quoteString) {
853-
while (substr($token, -1) !== $quoteString) {
854-
$nextToken = $this->scanner->fetchNextToken();
855-
if ('' === $nextToken) {
856-
break;
857-
}
858-
$token .= $this->scanner->getPreviousDelimiter();
859-
$token .= $nextToken;
860-
}
861-
862-
if (substr($token, -1) !== $quoteString) {
863-
throw new InvalidQueryException("Syntax error: unterminated quoted string $token in '{$this->sql2}'");
864-
}
865-
$token = substr($token, 1, -1);
866-
$token = str_replace('\\'.$quoteString, $quoteString, $token);
867-
$illegalCharacters = array(
868-
'\\!' => '!', '\\(' => '(', '\\:' => ':', '\\^' => '^',
869-
'\\[' => '[', '\\]' => ']', '\\{' => '{', '\\}' => '}',
870-
'\\\"' => '\"', '\\?' => '?', "''" => "'",
871-
);
872-
873-
$token = strtr($token, $illegalCharacters);
874-
875-
}
876-
877-
return $this->factory->literal($token);
878-
}
879832
/**
880833
* 6.7.37 Ordering
881834
*/

0 commit comments

Comments
 (0)