File tree Expand file tree Collapse file tree 6 files changed +40
-19
lines changed
lib/Doctrine/ORM/Query/AST Expand file tree Collapse file tree 6 files changed +40
-19
lines changed Original file line number Diff line number Diff line change 1616 */
1717class ComparisonExpression extends Node
1818{
19- /** @var Node */
19+ /** @var Node|string */
2020 public $ leftExpression ;
2121
22- /** @var Node */
22+ /** @var Node|string */
2323 public $ rightExpression ;
2424
2525 /** @var string */
2626 public $ operator ;
2727
2828 /**
29- * @param Node $leftExpr
30- * @param string $operator
31- * @param Node $rightExpr
29+ * @param Node|string $leftExpr
30+ * @param string $operator
31+ * @param Node|string $rightExpr
3232 */
3333 public function __construct ($ leftExpr , $ operator , $ rightExpr )
3434 {
Original file line number Diff line number Diff line change @@ -32,14 +32,20 @@ class LocateFunction extends FunctionNode
3232 */
3333 public function getSql (SqlWalker $ sqlWalker )
3434 {
35- return $ sqlWalker ->getConnection ()->getDatabasePlatform ()->getLocateExpression (
36- $ sqlWalker ->walkStringPrimary ($ this ->secondStringPrimary ), // its the other way around in platform
37- $ sqlWalker ->walkStringPrimary ($ this ->firstStringPrimary ),
38- ($ this ->simpleArithmeticExpression
39- ? $ sqlWalker ->walkSimpleArithmeticExpression ($ this ->simpleArithmeticExpression )
40- : false
41- )
42- );
35+ $ platform = $ sqlWalker ->getConnection ()->getDatabasePlatform ();
36+
37+ $ firstString = $ sqlWalker ->walkStringPrimary ($ this ->firstStringPrimary );
38+ $ secondString = $ sqlWalker ->walkStringPrimary ($ this ->secondStringPrimary );
39+
40+ if ($ this ->simpleArithmeticExpression ) {
41+ return $ platform ->getLocateExpression (
42+ $ secondString ,
43+ $ firstString ,
44+ $ sqlWalker ->walkSimpleArithmeticExpression ($ this ->simpleArithmeticExpression )
45+ );
46+ }
47+
48+ return $ platform ->getLocateExpression ($ secondString , $ firstString );
4349 }
4450
4551 /**
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ class TrimFunction extends FunctionNode
2828 /** @var bool */
2929 public $ both ;
3030
31- /** @var bool */
31+ /** @var string|false */
3232 public $ trimChar = false ;
3333
3434 /** @var Node */
@@ -42,11 +42,16 @@ public function getSql(SqlWalker $sqlWalker)
4242 $ stringPrimary = $ sqlWalker ->walkStringPrimary ($ this ->stringPrimary );
4343 $ platform = $ sqlWalker ->getConnection ()->getDatabasePlatform ();
4444 $ trimMode = $ this ->getTrimMode ();
45- $ trimChar = $ this ->trimChar !== false
46- ? $ sqlWalker ->getConnection ()->quote ($ this ->trimChar )
47- : false ;
4845
49- return $ platform ->getTrimExpression ($ stringPrimary , $ trimMode , $ trimChar );
46+ if ($ this ->trimChar !== false ) {
47+ return $ platform ->getTrimExpression (
48+ $ stringPrimary ,
49+ $ trimMode ,
50+ $ platform ->quoteStringLiteral ($ this ->trimChar )
51+ );
52+ }
53+
54+ return $ platform ->getTrimExpression ($ stringPrimary , $ trimMode );
5055 }
5156
5257 /**
Original file line number Diff line number Diff line change @@ -1498,7 +1498,7 @@ parameters:
14981498
14991499 -
15001500 message : " #^Else branch is unreachable because ternary operator condition is always true\\ .$#"
1501- count : 5
1501+ count : 1
15021502 path : lib/Doctrine/ORM/Query/SqlWalker.php
15031503
15041504 -
Original file line number Diff line number Diff line change @@ -25,3 +25,8 @@ parameters:
2525 message : ' /^Call to an undefined method Doctrine\\Common\\Cache\\Cache::deleteAll\(\)\.$/'
2626 count : 1
2727 path : lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php
28+ # See https://github.com/doctrine/dbal/pull/5129
29+ -
30+ message : ' /^Parameter #3 \$startPos of method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getLocateExpression\(\) expects int\|false, string given\.$/'
31+ count : 1
32+ path : lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php
Original file line number Diff line number Diff line change @@ -38,3 +38,8 @@ parameters:
3838 message : ' /^Call to an undefined method Doctrine\\Common\\Cache\\Cache::deleteAll\(\)\.$/'
3939 count : 1
4040 path : lib/Doctrine/ORM/Tools/Console/Command/ClearCache/ResultCommand.php
41+ # See https://github.com/doctrine/dbal/pull/5129
42+ -
43+ message : ' /^Parameter #3 \$startPos of method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getLocateExpression\(\) expects int\|false, string given\.$/'
44+ count : 1
45+ path : lib/Doctrine/ORM/Query/AST/Functions/LocateFunction.php
You can’t perform that action at this time.
0 commit comments