diff --git a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php index 775d70019..2da6fb412 100644 --- a/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php +++ b/lib/Doctrine/ORM/Query/QueryExpressionVisitor.php @@ -154,6 +154,11 @@ class QueryExpressionVisitor extends ExpressionVisitor $this->parameters[] = $parameter; return $this->expr->neq($comparison->getField(), $placeholder); + case Comparison::CONTAINS: + $parameter->setValue('%' . $parameter->getValue() . '%', $parameter->getType()); + $this->parameters[] = $parameter; + return $this->expr->like($comparison->getField(), $placeholder); + default: $operator = self::convertComparisonOperator($comparison->getOperator()); if ($operator) { diff --git a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php index 5eaeb7646..5c7a5b776 100644 --- a/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php +++ b/tests/Doctrine/Tests/ORM/Query/QueryExpressionVisitorTest.php @@ -85,6 +85,8 @@ class QueryExpressionVisitorTest extends \PHPUnit_Framework_TestCase array($cb->in('field', array('value')), $qb->in('field', ':field'), new Parameter('field', array('value'))), array($cb->notIn('field', array('value')), $qb->notIn('field', ':field'), new Parameter('field', array('value'))), + array($cb->contains('field', 'value'), $qb->like('field', ':field'), new Parameter('field', '%value%')), + // Test parameter conversion array($cb->eq('object.field', 'value'), $qb->eq('object.field', ':object_field'), new Parameter('object_field', 'value')), );