Merge pull request #791 from myclabs/CriteriaContains
Implemented "contains" operator for Criteria expressions
This commit is contained in:
commit
be81b46d8e
@ -154,6 +154,11 @@ class QueryExpressionVisitor extends ExpressionVisitor
|
|||||||
$this->parameters[] = $parameter;
|
$this->parameters[] = $parameter;
|
||||||
return $this->expr->neq($comparison->getField(), $placeholder);
|
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:
|
default:
|
||||||
$operator = self::convertComparisonOperator($comparison->getOperator());
|
$operator = self::convertComparisonOperator($comparison->getOperator());
|
||||||
if ($operator) {
|
if ($operator) {
|
||||||
|
@ -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->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->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
|
// Test parameter conversion
|
||||||
array($cb->eq('object.field', 'value'), $qb->eq('object.field', ':object_field'), new Parameter('object_field', 'value')),
|
array($cb->eq('object.field', 'value'), $qb->eq('object.field', ':object_field'), new Parameter('object_field', 'value')),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user