mirror of
https://github.com/bodyrep/bodyrep-sandpit.git
synced 2026-02-06 12:11:37 +00:00
neh
This commit is contained in:
186
br/doctrine-ilike.patch
Normal file
186
br/doctrine-ilike.patch
Normal file
@@ -0,0 +1,186 @@
|
||||
diff -Naur -X .ign vendor//doctrine/orm/lib/Doctrine/ORM/Query/AST/iLikeExpression.php bodyrep-vendor//doctrine/orm/lib/Doctrine/ORM/Query/AST/iLikeExpression.php
|
||||
--- vendor//doctrine/orm/lib/Doctrine/ORM/Query/AST/iLikeExpression.php 1970-01-01 10:00:00.000000000 +1000
|
||||
+++ bodyrep-vendor//doctrine/orm/lib/Doctrine/ORM/Query/AST/iLikeExpression.php 2012-09-19 01:40:50.000000000 +1000
|
||||
@@ -0,0 +1,49 @@
|
||||
+<?php
|
||||
+/*
|
||||
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+ *
|
||||
+ * This software consists of voluntary contributions made by many individuals
|
||||
+ * and is licensed under the MIT license. For more information, see
|
||||
+ * <http://www.doctrine-project.org>.
|
||||
+ */
|
||||
+namespace Doctrine\ORM\Query\AST;
|
||||
+
|
||||
+/**
|
||||
+ * iLikeExpression ::= StringExpression ["NOT"] "ILIKE" string ["ESCAPE" char]
|
||||
+ *
|
||||
+ *
|
||||
+ * @link www.doctrine-project.org
|
||||
+ * @since 2.0
|
||||
+ * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
|
||||
+ * @author Jonathan Wage <jonwage@gmail.com>
|
||||
+ * @author Roman Borschel <roman@code-factory.org>
|
||||
+ */
|
||||
+class iLikeExpression extends Node
|
||||
+{
|
||||
+ public $not;
|
||||
+ public $stringExpression;
|
||||
+ public $stringPattern;
|
||||
+ public $escapeChar;
|
||||
+
|
||||
+ public function __construct($stringExpression, $stringPattern, $escapeChar = null)
|
||||
+ {
|
||||
+ $this->stringExpression = $stringExpression;
|
||||
+ $this->stringPattern = $stringPattern;
|
||||
+ $this->escapeChar = $escapeChar;
|
||||
+ }
|
||||
+
|
||||
+ public function dispatch($sqlWalker)
|
||||
+ {
|
||||
+ return $sqlWalker->walkiLikeExpression($this);
|
||||
+ }
|
||||
+}
|
||||
diff -Naur -X .ign vendor//doctrine/orm/lib/Doctrine/ORM/Query/Expr.php bodyrep-vendor//doctrine/orm/lib/Doctrine/ORM/Query/Expr.php
|
||||
--- vendor//doctrine/orm/lib/Doctrine/ORM/Query/Expr.php 2012-09-18 02:35:14.000000000 +1000
|
||||
+++ bodyrep-vendor//doctrine/orm/lib/Doctrine/ORM/Query/Expr.php 2012-09-19 01:28:50.000000000 +1000
|
||||
@@ -479,6 +479,11 @@
|
||||
return new Expr\Comparison($x, 'LIKE', $y);
|
||||
}
|
||||
|
||||
+ public function ilike($x, $y)
|
||||
+ {
|
||||
+ return new Expr\Comparison($x, 'ILIKE', $y);
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Creates a CONCAT() function expression with the given arguments.
|
||||
*
|
||||
diff -Naur -X .ign vendor//doctrine/orm/lib/Doctrine/ORM/Query/Lexer.php bodyrep-vendor//doctrine/orm/lib/Doctrine/ORM/Query/Lexer.php
|
||||
--- vendor//doctrine/orm/lib/Doctrine/ORM/Query/Lexer.php 2012-09-18 02:35:14.000000000 +1000
|
||||
+++ bodyrep-vendor//doctrine/orm/lib/Doctrine/ORM/Query/Lexer.php 2012-09-19 01:38:54.000000000 +1000
|
||||
@@ -86,6 +86,7 @@
|
||||
const T_LEADING = 132;
|
||||
const T_LEFT = 133;
|
||||
const T_LIKE = 134;
|
||||
+ const T_ILIKE = 157;
|
||||
const T_MAX = 135;
|
||||
const T_MEMBER = 136;
|
||||
const T_MIN = 137;
|
||||
diff -Naur -X .ign vendor//doctrine/orm/lib/Doctrine/ORM/Query/Parser.php bodyrep-vendor//doctrine/orm/lib/Doctrine/ORM/Query/Parser.php
|
||||
--- vendor//doctrine/orm/lib/Doctrine/ORM/Query/Parser.php 2012-09-18 02:35:14.000000000 +1000
|
||||
+++ bodyrep-vendor//doctrine/orm/lib/Doctrine/ORM/Query/Parser.php 2012-09-19 01:38:04.000000000 +1000
|
||||
@@ -2183,7 +2183,7 @@
|
||||
$peek = $this->_peekBeyondClosingParenthesis();
|
||||
|
||||
if (in_array($peek['value'], array("=", "<", "<=", "<>", ">", ">=", "!=")) ||
|
||||
- in_array($peek['type'], array(Lexer::T_NOT, Lexer::T_BETWEEN, Lexer::T_LIKE, Lexer::T_IN, Lexer::T_IS, Lexer::T_EXISTS)) ||
|
||||
+ in_array($peek['type'], array(Lexer::T_NOT, Lexer::T_BETWEEN, Lexer::T_LIKE, Lexer::T_ILIKE, Lexer::T_IN, Lexer::T_IS, Lexer::T_EXISTS)) ||
|
||||
$this->_isMathOperator($peek)) {
|
||||
$condPrimary->simpleConditionalExpression = $this->SimpleConditionalExpression();
|
||||
|
||||
@@ -2260,6 +2260,8 @@
|
||||
switch ($token['type']) {
|
||||
case Lexer::T_BETWEEN:
|
||||
return $this->BetweenExpression();
|
||||
+ case Lexer::T_ILIKE:
|
||||
+ return $this->iLikeExpression();
|
||||
case Lexer::T_LIKE:
|
||||
return $this->LikeExpression();
|
||||
case Lexer::T_IN:
|
||||
@@ -2889,6 +2891,45 @@
|
||||
|
||||
return $likeExpr;
|
||||
}
|
||||
+ /**
|
||||
+ * iLikeExpression ::= StringExpression ["NOT"] "ILIKE" StringPrimary ["ESCAPE" char]
|
||||
+ *
|
||||
+ * @return \Doctrine\ORM\Query\AST\iLikeExpression
|
||||
+ */
|
||||
+ public function iLikeExpression()
|
||||
+ {
|
||||
+ $stringExpr = $this->StringExpression();
|
||||
+ $not = false;
|
||||
+
|
||||
+ if ($this->_lexer->isNextToken(Lexer::T_NOT)) {
|
||||
+ $this->match(Lexer::T_NOT);
|
||||
+ $not = true;
|
||||
+ }
|
||||
+
|
||||
+ $this->match(Lexer::T_ILIKE);
|
||||
+
|
||||
+ if ($this->_lexer->isNextToken(Lexer::T_INPUT_PARAMETER)) {
|
||||
+ $this->match(Lexer::T_INPUT_PARAMETER);
|
||||
+ $stringPattern = new AST\InputParameter($this->_lexer->token['value']);
|
||||
+ } else {
|
||||
+ $stringPattern = $this->StringPrimary();
|
||||
+ }
|
||||
+
|
||||
+ $escapeChar = null;
|
||||
+
|
||||
+ if ($this->_lexer->lookahead['type'] === Lexer::T_ESCAPE) {
|
||||
+ $this->match(Lexer::T_ESCAPE);
|
||||
+ $this->match(Lexer::T_STRING);
|
||||
+
|
||||
+ $escapeChar = new AST\Literal(AST\Literal::STRING, $this->_lexer->token['value']);
|
||||
+ }
|
||||
+
|
||||
+ $likeExpr = new AST\iLikeExpression($stringExpr, $stringPattern, $escapeChar);
|
||||
+ $likeExpr->not = $not;
|
||||
+
|
||||
+ return $likeExpr;
|
||||
+ }
|
||||
+
|
||||
|
||||
/**
|
||||
* NullComparisonExpression ::= (SingleValuedPathExpression | InputParameter) "IS" ["NOT"] "NULL"
|
||||
diff -Naur -X .ign vendor//doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php bodyrep-vendor//doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php
|
||||
--- vendor//doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php 2012-09-18 02:35:14.000000000 +1000
|
||||
+++ bodyrep-vendor//doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php 2012-09-19 01:41:30.000000000 +1000
|
||||
@@ -2028,6 +2028,36 @@
|
||||
return $sql;
|
||||
}
|
||||
|
||||
+ /**
|
||||
+ * Walks down a iLikeExpression AST node, thereby generating the appropriate SQL.
|
||||
+ *
|
||||
+ * @param iLikeExpression
|
||||
+ * @return string The SQL.
|
||||
+ */
|
||||
+ public function walkiLikeExpression($likeExpr)
|
||||
+ {
|
||||
+ $stringExpr = $likeExpr->stringExpression;
|
||||
+ $sql = $stringExpr->dispatch($this) . ($likeExpr->not ? ' NOT' : '') . ' ILIKE ';
|
||||
+
|
||||
+ if ($likeExpr->stringPattern instanceof AST\InputParameter) {
|
||||
+ $inputParam = $likeExpr->stringPattern;
|
||||
+ $dqlParamKey = $inputParam->name;
|
||||
+ $this->parserResult->addParameterMapping($dqlParamKey, $this->sqlParamIndex++);
|
||||
+ $sql .= '?';
|
||||
+ } elseif ($likeExpr->stringPattern instanceof AST\Functions\FunctionNode ) {
|
||||
+ $sql .= $this->walkFunction($likeExpr->stringPattern);
|
||||
+ } elseif ($likeExpr->stringPattern instanceof AST\PathExpression) {
|
||||
+ $sql .= $this->walkPathExpression($likeExpr->stringPattern);
|
||||
+ } else {
|
||||
+ $sql .= $this->walkLiteral($likeExpr->stringPattern);
|
||||
+ }
|
||||
+
|
||||
+ if ($likeExpr->escapeChar) {
|
||||
+ $sql .= ' ESCAPE ' . $this->walkLiteral($likeExpr->escapeChar);
|
||||
+ }
|
||||
+
|
||||
+ return $sql;
|
||||
+ }
|
||||
/**
|
||||
* Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL.
|
||||
*
|
||||
Reference in New Issue
Block a user