commit
6103db0d04
@ -53,7 +53,7 @@ class ModFunction extends FunctionNode
|
|||||||
*/
|
*/
|
||||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||||
{
|
{
|
||||||
$parser->match(Lexer::T_MOD);
|
$parser->match(Lexer::T_IDENTIFIER);
|
||||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||||
|
|
||||||
$this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
$this->firstSimpleArithmeticExpression = $parser->SimpleArithmeticExpression();
|
||||||
|
@ -109,7 +109,7 @@ class SizeFunction extends FunctionNode
|
|||||||
*/
|
*/
|
||||||
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
public function parse(\Doctrine\ORM\Query\Parser $parser)
|
||||||
{
|
{
|
||||||
$parser->match(Lexer::T_SIZE);
|
$parser->match(Lexer::T_IDENTIFIER);
|
||||||
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
$parser->match(Lexer::T_OPEN_PARENTHESIS);
|
||||||
|
|
||||||
$this->collectionPathExpression = $parser->CollectionValuedPathExpression();
|
$this->collectionPathExpression = $parser->CollectionValuedPathExpression();
|
||||||
|
@ -98,18 +98,16 @@ class Lexer extends \Doctrine\Common\Lexer
|
|||||||
const T_OUTER = 144;
|
const T_OUTER = 144;
|
||||||
const T_SELECT = 145;
|
const T_SELECT = 145;
|
||||||
const T_SET = 146;
|
const T_SET = 146;
|
||||||
const T_SIZE = 147;
|
const T_SOME = 147;
|
||||||
const T_SOME = 148;
|
const T_SUM = 148;
|
||||||
const T_SUM = 149;
|
const T_THEN = 149;
|
||||||
const T_THEN = 150;
|
const T_TRAILING = 150;
|
||||||
const T_TRAILING = 151;
|
const T_TRUE = 151;
|
||||||
const T_TRUE = 152;
|
const T_UPDATE = 152;
|
||||||
const T_UPDATE = 153;
|
const T_WHEN = 153;
|
||||||
const T_WHEN = 154;
|
const T_WHERE = 154;
|
||||||
const T_WHERE = 155;
|
const T_WITH = 155;
|
||||||
const T_WITH = 156;
|
const T_PARTIAL = 156;
|
||||||
const T_PARTIAL = 157;
|
|
||||||
const T_MOD = 158;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new query scanner object.
|
* Creates a new query scanner object.
|
||||||
|
@ -416,9 +416,10 @@ class Parser
|
|||||||
/**
|
/**
|
||||||
* Peek beyond the matched closing parenthesis and return the first token after that one.
|
* Peek beyond the matched closing parenthesis and return the first token after that one.
|
||||||
*
|
*
|
||||||
|
* @param boolean $resetPeek Reset peek after finding the closing parenthesis
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function _peekBeyondClosingParenthesis()
|
private function _peekBeyondClosingParenthesis($resetPeek = true)
|
||||||
{
|
{
|
||||||
$token = $this->_lexer->peek();
|
$token = $this->_lexer->peek();
|
||||||
$numUnmatched = 1;
|
$numUnmatched = 1;
|
||||||
@ -440,7 +441,9 @@ class Parser
|
|||||||
$token = $this->_lexer->peek();
|
$token = $this->_lexer->peek();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($resetPeek) {
|
||||||
$this->_lexer->resetPeek();
|
$this->_lexer->resetPeek();
|
||||||
|
}
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
@ -2206,7 +2209,13 @@ class Parser
|
|||||||
if ($peek['value'] == '(') {
|
if ($peek['value'] == '(') {
|
||||||
// Peek beyond the matching closing paranthesis ')'
|
// Peek beyond the matching closing paranthesis ')'
|
||||||
$this->_lexer->peek();
|
$this->_lexer->peek();
|
||||||
$token = $this->_peekBeyondClosingParenthesis();
|
$token = $this->_peekBeyondClosingParenthesis(false);
|
||||||
|
|
||||||
|
if ($token['type'] === Lexer::T_NOT) {
|
||||||
|
$token = $this->_lexer->peek();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_lexer->resetPeek();
|
||||||
} else {
|
} else {
|
||||||
// Peek beyond the PathExpression (or InputParameter)
|
// Peek beyond the PathExpression (or InputParameter)
|
||||||
$peek = $this->_lexer->peek();
|
$peek = $this->_lexer->peek();
|
||||||
|
@ -374,6 +374,17 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-1802
|
||||||
|
*/
|
||||||
|
public function testSupportsNotBetweenForSizeFunction()
|
||||||
|
{
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
"SELECT m.name FROM Doctrine\Tests\Models\StockExchange\Market m WHERE SIZE(m.stocks) NOT BETWEEN ?1 AND ?2",
|
||||||
|
"SELECT e0_.name AS name0 FROM exchange_markets e0_ WHERE (SELECT COUNT(*) FROM exchange_stocks e1_ WHERE e1_.market_id = e0_.id) NOT BETWEEN ? AND ?"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testSupportsFunctionalExpressionsInWherePart()
|
public function testSupportsFunctionalExpressionsInWherePart()
|
||||||
{
|
{
|
||||||
$this->assertSqlGeneration(
|
$this->assertSqlGeneration(
|
||||||
@ -472,6 +483,17 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-1802
|
||||||
|
*/
|
||||||
|
public function testSupportsNotInExpressionForModFunction()
|
||||||
|
{
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE MOD(u.id, 5) NOT IN(1,3,4)",
|
||||||
|
"SELECT c0_.name AS name0 FROM cms_users c0_ WHERE MOD(c0_.id, 5) NOT IN (1, 3, 4)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testInExpressionWithSingleValuedAssociationPathExpressionInWherePart()
|
public function testInExpressionWithSingleValuedAssociationPathExpressionInWherePart()
|
||||||
{
|
{
|
||||||
$this->assertSqlGeneration(
|
$this->assertSqlGeneration(
|
||||||
@ -854,6 +876,26 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-1802
|
||||||
|
*/
|
||||||
|
public function testStringFunctionNotLikeExpression()
|
||||||
|
{
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE LOWER(u.name) NOT LIKE '%foo OR bar%'",
|
||||||
|
"SELECT c0_.name AS name0 FROM cms_users c0_ WHERE LOWER(c0_.name) NOT LIKE '%foo OR bar%'"
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE UPPER(LOWER(u.name)) NOT LIKE UPPER(LOWER(:str))",
|
||||||
|
"SELECT c0_.name AS name0 FROM cms_users c0_ WHERE UPPER(LOWER(c0_.name)) NOT LIKE UPPER(LOWER(?))"
|
||||||
|
);
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a WITH a.topic NOT LIKE u.name",
|
||||||
|
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LEFT JOIN cms_articles c1_ ON c0_.id = c1_.user_id AND (c1_.topic NOT LIKE c0_.name)"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group DDC-338
|
* @group DDC-338
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user