Пример #1
0
 public function predicateData()
 {
     $nameEq = (new EqualPredicate())->setField('name')->setExpression(ValueExpression::create('test'));
     $set = new PredicateSet();
     $set->addPredicate($nameEq);
     return [[['name' => 'test'], [$nameEq]], [[$nameEq], [$nameEq]], [['AND' => ['name' => 'test']], [$set]]];
 }
Пример #2
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Cannot have multiple predicate sets in CQL
  */
 public function testMultiplePredicatesFail()
 {
     $where = WhereClause::create();
     $set = new PredicateSet();
     $set->addPredicate(new PredicateSet());
     $where->addPredicate($set);
     CqlAssembler::stringify($where);
 }
Пример #3
0
 public function andWhere(...$expressions)
 {
     $currentSet = $this->_getCurrentSet();
     $newSet = $this->_getNewSet($expressions);
     $finalSet = new PredicateSet();
     $finalSet->addPredicate($currentSet);
     $finalSet->addPredicate($newSet);
     /**
      * @var $this  IStatement
      * @var $where WhereClause
      */
     $where = $this->getClause('WHERE');
     $where->clearPredicates();
     $where->addPredicate($finalSet);
     $this->addClause($where);
     return $this;
 }
Пример #4
0
 public function testGettersAndSetters()
 {
     $set = new PredicateSet();
     $eq = new EqualPredicate();
     $neq = new NotEqualPredicate();
     $this->assertFalse($set->hasPredicates());
     $set->addPredicate($eq);
     $this->assertTrue($set->hasPredicates());
     $this->assertSame([$eq], $set->getPredicates());
     $set->clearPredicates();
     $set->setPredicates([$eq, $neq]);
     $this->assertTrue($set->hasPredicates());
     $set->clearPredicates();
     $this->assertFalse($set->hasPredicates());
     $this->setExpectedException("InvalidArgumentException");
     $set->setPredicates([$eq, $neq, 'abc']);
 }
Пример #5
0
 public function assembleBetween(BetweenPredicate $betweenPredicate)
 {
     $gte = new GreaterThanOrEqualPredicate();
     $gte->setField($betweenPredicate->getField());
     $lte = new LessThanOrEqualPredicate();
     $lte->setField($betweenPredicate->getField());
     $set = new PredicateSet();
     if ($betweenPredicate instanceof NotBetweenPredicate) {
         $gte->setExpression($betweenPredicate->getRangeEnd());
         $lte->setExpression($betweenPredicate->getRangeStart());
         $set->addPredicate($lte);
         $set->addPredicate($gte);
     } else {
         $gte->setExpression($betweenPredicate->getRangeStart());
         $lte->setExpression($betweenPredicate->getRangeEnd());
         $set->addPredicate($gte);
         $set->addPredicate($lte);
     }
     return $this->assembleSegment($set);
 }