/**
  * {@inheritdoc}
  */
 protected function doWalkComparison($fieldName, $operator, $placeholder)
 {
     switch ($operator) {
         case Comparison::IN:
             return $this->expr->in($fieldName, $placeholder);
         case Comparison::NIN:
             return $this->expr->notIn($fieldName, $placeholder);
         case Comparison::EQ:
         case Comparison::IS:
             if ($placeholder === null) {
                 return $this->expr->isNull($fieldName);
             }
             return $this->expr->eq($fieldName, $placeholder);
         case Comparison::NEQ:
             if ($placeholder === null) {
                 return $this->expr->isNotNull($fieldName);
             }
             return $this->expr->neq($fieldName, $placeholder);
         case Comparison::CONTAINS:
             return $this->expr->like($fieldName, $placeholder);
         default:
             $operator = self::convertComparisonOperator($operator);
             if ($operator) {
                 return $this->expr->comparison($fieldName, $operator, $placeholder);
             }
             throw new \RuntimeException("Unknown comparison operator: " . $operator);
     }
 }
Esempio n. 2
0
 /**
  * Creates a comparison expression.
  *
  * @param mixed $x The left expression.
  * @param string $operator One of the ExpressionBuilder::* constants.
  * @param mixed $y The right expression.
  *
  * @return string
  */
 public function comparison($x, $operator, $y)
 {
     $x = $this->helper->quoteColumnName($x);
     $y = $this->helper->quoteColumnName($y);
     return $this->expressionBuilder->comparison($x, $operator, $y);
 }
Esempio n. 3
0
 /**
  * @dataProvider dataComparison
  *
  * @param string $comparison
  * @param mixed $input1
  * @param bool $isInput1Literal
  * @param mixed $input2
  * @param bool $isInput2Literal
  */
 public function testComparison($comparison, $input1, $isInput1Literal, $input2, $isInput2Literal)
 {
     list($doctrineInput1, $ocInput1) = $this->helpWithLiteral($input1, $isInput1Literal);
     list($doctrineInput2, $ocInput2) = $this->helpWithLiteral($input2, $isInput2Literal);
     $this->assertEquals($this->doctrineExpressionBuilder->comparison($doctrineInput1, $comparison, $doctrineInput2), $this->expressionBuilder->comparison($ocInput1, $comparison, $ocInput2));
 }
 /**
  * Creates a ILIKE() comparison expression with the given arguments.
  *
  * @param string $x Field in string format to be inspected by ILIKE() comparison.
  * @param mixed $y Argument to be used in ILIKE() comparison.
  * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants
  *                  required when comparing text fields for oci compatibility
  *
  * @return string
  * @since 9.0.0
  */
 public function iLike($x, $y, $type = null)
 {
     $x = $this->helper->quoteColumnName($x);
     $y = $this->helper->quoteColumnName($y);
     return $this->expressionBuilder->comparison("LOWER({$x})", 'LIKE', "LOWER({$y})");
 }