Ilike #654

Closed
wants to merge 1 commit into
from

Projects

None yet

6 participants

@lighthart

Ilike (insensitive like) expression added for postgres support

@Majkl578

Ilike is platform-dependent, it should not be part of Doctrine itself.
By the way, this might be a good time to propose some kind of user-land AST extendability. Once I wanted to extend AST by custom syntax and found out it is not possible at all.

@Majkl578 Majkl578 commented on the diff Apr 27, 2013
tests/Doctrine/Tests/ORM/Query/ExprTest.php
@@ -173,11 +173,21 @@ public function testLikeExpr()
$this->assertEquals('a.description LIKE :description', (string) $this->_expr->like('a.description', ':description'));
}
+ public function testLikeExpr()
@Majkl578
Majkl578 Apr 27, 2013

You probably meant testILikeExpr, since this one is already declared.

@Majkl578 Majkl578 commented on the diff Apr 27, 2013
tests/Doctrine/Tests/ORM/Query/ExprTest.php
public function testNotLikeExpr()
{
$this->assertEquals('a.description NOT LIKE :description', (string) $this->_expr->notLike('a.description', ':description'));
}
+ public function testNotLikeExpr()
@Majkl578
Majkl578 Apr 27, 2013

Same here, testNotILikeExpr.

@Majkl578 Majkl578 commented on the diff Apr 27, 2013
lib/Doctrine/ORM/Query/TreeWalker.php
@@ -379,6 +379,15 @@ function walkBetweenExpression($betweenExpr);
function walkLikeExpression($likeExpr);
/**
+ * Walks down a IlikeExpression AST node, thereby generating the appropriate SQL.
+ *
+ * @param AST\IlikeExpression $ilikeExpr
+ *
+ * @return string The SQL.
+ */
+ function walkIlikeExpression($ilikeExpr);
@Majkl578
Majkl578 Apr 27, 2013

Adding this method would be a BC break.

@mvrhov

According to the SQL standard LIKE is supposed to be case insensitive.. PostgreSQL makes it case sensitive so ORM should use ILIKE on PostgreSQL platform by default. However changing this would be a BC break.

@beberlei
Doctrine member

The same is a problem for Sqlite which is case sensitive by default afaik, in MySQL it depends on the collation. I don't think we can find a sufficient solution here that works on all platforms.

I have to reject this PR, because its PostgreSQL specific and DQL is platform independent. You can "fix" this for you, by extending the PostgreSQLPlatform in DBAL and changing the LIKE Expression for Postrgres.

@beberlei beberlei closed this Apr 27, 2013
@greg0ire

You can "fix" this for you, by extending the PostgreSQLPlatform in DBAL and changing the LIKE Expression for Postrgres.

Sorry to dig that up, but there is no getLikeExpression() or something like that, LIKE is hardcoded here I believe : https://github.com/doctrine/doctrine2/blob/c1943624ab1260c629316bab104dc5130c060154/lib/Doctrine/ORM/Query/SqlWalker.php#L2162

@Ocramius
Doctrine member

What @beberlei meant here is probably defining a custom DQL string function.

@greg0ire

Thanks for clarifying that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment