Skip to content

fix previous refactoring of parseLiteral() to parseListeralValue() #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 2 additions & 49 deletions src/PHPCR/Util/QOM/Sql2ToQomQueryConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,15 +772,15 @@ protected function parseCastLiteral($token)
throw new InvalidQueryException("Syntax error: attempting to cast string '$token' to type '$type'");
}

return $this->factory->literal($token);
return $token;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. did you grep if we have other places that could have similar issues?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue is limited to places where we return in parseLiteralValue() and all of these cases are now covered.

}
}

/**
* 6.7.34 Literal
* Parse an SQL2 literal value
*
* @return LiteralInterface
* @return mixed
*/
protected function parseLiteralValue()
{
Expand Down Expand Up @@ -829,53 +829,6 @@ protected function parseLiteralValue()
return $token;
}

/**
* 6.7.34 Fulltext Literal
* Parse an SQL2 literal value
*
* @return LiteralInterface
*/
protected function parseFulltextLiteral()
{
$token = $this->scanner->fetchNextToken();
if ($this->scanner->tokenIs($token, 'CAST')) {
return $this->parseCastLiteral($token);
}

$quoteString = false;
if (substr($token, 0, 1) === '\'') {
$quoteString = "'";
} elseif (substr($token, 0, 1) === '"') {
$quoteString = '"';
}

if ($quoteString) {
while (substr($token, -1) !== $quoteString) {
$nextToken = $this->scanner->fetchNextToken();
if ('' === $nextToken) {
break;
}
$token .= $this->scanner->getPreviousDelimiter();
$token .= $nextToken;
}

if (substr($token, -1) !== $quoteString) {
throw new InvalidQueryException("Syntax error: unterminated quoted string $token in '{$this->sql2}'");
}
$token = substr($token, 1, -1);
$token = str_replace('\\'.$quoteString, $quoteString, $token);
$illegalCharacters = array(
'\\!' => '!', '\\(' => '(', '\\:' => ':', '\\^' => '^',
'\\[' => '[', '\\]' => ']', '\\{' => '{', '\\}' => '}',
'\\\"' => '\"', '\\?' => '?', "''" => "'",
);

$token = strtr($token, $illegalCharacters);

}

return $this->factory->literal($token);
}
/**
* 6.7.37 Ordering
*/
Expand Down