/**
  * Hop callback which called from Ticker
  *
  * @param $hopId
  * @param $ttl
  */
 public function processHop($hopId, $ttl)
 {
     /**
      * One more reads active filters from DataStore and further use it ever tick
      */
     $query = new Query();
     $query->setQuery(new ScalarOperator\EqNode('active', 1));
     $this->filters = $this->dataStore->query($query);
 }
 public function getAll()
 {
     if ($this->notificationType === null) {
         throw new \Exception("Not set notification Type");
     }
     $query = new Query();
     $query->setQuery(new EqNode(AllNotificationDataStoreFactory::KEY_EBAY_NOTIFICATION_TYPE, $this->notificationType));
     return $this->dataByType($this->dataStore->query($query));
 }
Exemple #3
0
 protected function preQuery(Query &$query)
 {
     $scriptNameNode = new EqNode('scriptName', $this->scriptName);
     if ($query->getQuery()) {
         $query->setQuery(new AndNode([$scriptNameNode, $query->getQuery()]));
     } else {
         $query->setQuery($scriptNameNode);
     }
 }
 /**
  * @return void
  */
 public function testOnKernelResponseProcessed()
 {
     $query = new Query();
     $query->setSelect(new SelectNode(['a', 'b']));
     $request = new Request();
     $request->attributes->set('rqlQuery', $query);
     $response = new Response();
     $response->setContent('[{"a":1},{"b":2}]');
     $this->handleValidEvent($request, $response, [__METHOD__, __METHOD__]);
     $this->assertEquals(json_encode([__METHOD__, __METHOD__]), $response->getContent());
 }
Exemple #5
0
 public function setUp()
 {
     $this->queryObject = new Query();
     $this->queryObject->setQuery(new AndNode([new AndNode([new EqNode('q', null), new NeNode('q', null), new LeNode('q', 'r'), new GeNode('q', 'u')]), new OrNode([new LtNode('q', 't'), new GtNode('q', 'y'), new InNode('q', ['a', 's', 'd', 'f', 'g'])])]));
     $this->queryObject->setSelect(new XSelectNode(['q', new AggregateFunctionNode('max', 'q'), new AggregateFunctionNode('min', 'q'), new AggregateFunctionNode('count', 'q')]));
     $this->queryObject->setSort(new SortNode(['q' => -1, 'w' => 1, 'e' => 1]));
     $this->queryObject->setLimit(new LimitNode(20, 30));
     $this->rqlString = "and(and(eq(q,null()),ne(q,null()),le(q,r),ge(q,u)),or(lt(q,t),gt(q,y),in(q,(a,s,d,f,g))))";
     $this->rqlString .= "&limit(20,30)";
     $this->rqlString .= "&sort(-q,+w,e)";
     $this->rqlString .= "&select(q,max(q),min(q),count(q))";
 }
 /**
  * Test RqlAllowedOperatorRequestListener::onKernelRequest() with non-matched route
  *
  * @return void
  */
 public function testOnKernelRequestWithNonMatchedRoute()
 {
     $query = new Query();
     $query->setLimit(new LimitNode(1, 1));
     $request = new Request();
     $request->attributes->set('rqlQuery', $query);
     $request->attributes->set('_route', 'model.all');
     $event = new RestEvent();
     $event->setRequest($request);
     $listener = new RqlAllowedOperatorRequestListener();
     $listener->onKernelRequest($event);
 }
Exemple #7
0
 public function test_updateTaskSchedule()
 {
     $this->_initTask();
     $seconds = [];
     $currentTime = date('i');
     for ($i = 0; $i < 2; $i++) {
         $seconds[] = new EqNode('minutes', $currentTime + $i);
     }
     $query = new Query();
     $query->setQuery(new OrNode($seconds));
     $this->task->setSchedule($query);
     $this->assertEquals('ky', $this->task->activate(UTCTime::getUTCTimestamp(0), 1));
 }
 public function provider_query()
 {
     $emptyQuery = new Query();
     $queryWithAndNode = new Query();
     $queryWithAndNode->setQuery(new AndNode([new LtNode('price', 23), new NeNode('icon', 'icon1.jpg')]));
     $queryWithSelect = new Query();
     $queryWithSelect->setSelect(new SelectNode(['price', 'icon']));
     $queryWithSort = new Query();
     $queryWithSort->setSort(new SortNode(['price' => -1, 'icon' => +1]));
     $queryWithSelectProps = new Query();
     $queryWithSelectProps->setSelect(new SelectNode([StoreCatalog::PROP_LINKED_URL_TABLE_NAME]));
     return array(array($emptyQuery, array(['title' => 'Plate41-mainicon', 'price' => '21', 'icon' => 'icon1.jpg'], ['title' => 'Plate42-mainicon', 'price' => '22', 'icon' => 'icon2.jpg'], ['title' => 'Plate43-mainicon', 'price' => '23', 'icon' => 'icon3.jpg']), array(['title' => 'Plate41-mainicon', 'price' => '21', 'icon' => 'icon1.jpg'], ['title' => 'Plate42-mainicon', 'price' => '22', 'icon' => 'icon2.jpg'], ['title' => 'Plate43-mainicon', 'price' => '23', 'icon' => 'icon3.jpg'])), array($queryWithAndNode, array(['title' => 'Plate41-mainicon', 'price' => '21', 'icon' => 'icon1.jpg'], ['title' => 'Plate42-mainicon', 'price' => '22', 'icon' => 'icon2.jpg'], ['title' => 'Plate43-mainicon', 'price' => '23', 'icon' => 'icon3.jpg']), array(['title' => 'Plate42-mainicon', 'price' => '22', 'icon' => 'icon2.jpg'])), array($queryWithSelect, array(['title' => 'Plate41-mainicon', 'price' => '21', 'icon' => 'icon1.jpg'], ['title' => 'Plate42-mainicon', 'price' => '22', 'icon' => 'icon2.jpg'], ['title' => 'Plate43-mainicon', 'price' => '23', 'icon' => 'icon3.jpg']), array(['price' => '21', 'icon' => 'icon1.jpg'], ['price' => '22', 'icon' => 'icon2.jpg'], ['price' => '23', 'icon' => 'icon3.jpg'])), array($queryWithSort, array(['title' => 'Plate43-mainicon', 'price' => '23', 'icon' => 'icon6.jpg'], ['title' => 'Plate41-mainicon', 'price' => '21', 'icon' => 'icon1.jpg'], ['title' => 'Plate42-mainicon', 'price' => '22', 'icon' => 'icon2.jpg'], ['title' => 'Plate43-mainicon', 'price' => '22', 'icon' => 'icon3.jpg'], ['title' => 'Plate43-mainicon', 'price' => '23', 'icon' => 'icon5.jpg']), array(['title' => 'Plate43-mainicon', 'price' => '23', 'icon' => 'icon5.jpg'], ['title' => 'Plate43-mainicon', 'price' => '23', 'icon' => 'icon6.jpg'], ['title' => 'Plate42-mainicon', 'price' => '22', 'icon' => 'icon2.jpg'], ['title' => 'Plate43-mainicon', 'price' => '22', 'icon' => 'icon3.jpg'], ['title' => 'Plate41-mainicon', 'price' => '21', 'icon' => 'icon1.jpg'])), array($queryWithSelectProps, array(['title' => 'Plate41-mainicon', 'price' => '21', 'icon' => 'icon1.jpg', StoreCatalog::PROP_LINKED_URL_TABLE_NAME => [['url' => 'http://google.com', 'alt' => 'Pot1'], ['url' => 'http://google.com1', 'alt' => 'Pot2']]], ['title' => 'Plate42-mainicon', 'price' => '22', 'icon' => 'icon2.jpg', StoreCatalog::PROP_LINKED_URL_TABLE_NAME => [['url' => 'http://google.com2', 'alt' => 'Pot3'], ['url' => 'http://google.com3', 'alt' => 'Pot4']]]), array(['title' => 'Plate41-mainicon', 'price' => '21', 'icon' => 'icon1.jpg', StoreCatalog::PROP_LINKED_URL_TABLE_NAME => [['url' => 'http://google.com', 'alt' => 'Pot1'], ['url' => 'http://google.com1', 'alt' => 'Pot2']]], ['title' => 'Plate42-mainicon', 'price' => '22', 'icon' => 'icon2.jpg', StoreCatalog::PROP_LINKED_URL_TABLE_NAME => [['url' => 'http://google.com2', 'alt' => 'Pot3'], ['url' => 'http://google.com3', 'alt' => 'Pot4']]])));
 }
 public function canCreate(ContainerInterface $container, $requestedName)
 {
     if ($requestedName === self::KEY_CACHEABLE_NOTIFICATION_TYPE) {
         $this::$flag = true;
         return true;
     } else {
         /** @var DataStoresInterface $allNotification */
         $allNotification = $container->get($this::KEY_ALL_NOTIFICATION);
         $query = new Query();
         $query->setQuery(new EqNode(AllNotificationDataStoreFactory::KEY_EBAY_NOTIFICATION_TYPE, $requestedName));
         $result = $allNotification->query($query);
     }
     return count($result) > 0;
 }
 public function getConfiguration()
 {
     if ($this->dataStore instanceof ConfigurableInterface) {
         return $this->dataStore->getConfiguration();
     }
     $query = new Query();
     $query->setLimit(new LimitNode(1));
     $data = $this->dataStore->query($query);
     $config = [];
     if (count($data) > 0 and isset($data[0])) {
         foreach ($data[0] as $key => $value) {
             $config[] = ['label' => $key, 'field' => $key];
         }
     }
     return $config;
 }
 protected function addTickLimit(Query $query, $timeStart, $step)
 {
     $field = $step < 1 ? 'id' : 'timestamp';
     $andNode = new LogicOperator\AndNode([$query->getQuery(), new ScalarOperator\GeNode($field, $timeStart), new ScalarOperator\LtNode($field, $timeStart + $step)]);
     $query->setQuery($andNode);
     return $query;
 }
 protected function postQuery(&$result, Query $query)
 {
     if ($query->getQuery()) {
         if (count($result) === 0) {
             $queryStr = urldecode(RqlParser::rqlEncode($query));
             $pattern = '/^and\\(eq\\(tableName\\,([a-zA-Z0-9_]+)\\)\\,eq\\(name\\,_default\\)\\)/';
             $match = [];
             if (preg_match($pattern, $queryStr, $match)) {
                 $requestName = isset($match[1]) ? $match[1] : "";
                 $configuration = $this->configureGeneratorFactory->__invoke($requestName)->getConfiguration();
                 $res = ['table_name' => $requestName, 'name' => '_default', 'preference' => json_encode($configuration)];
                 foreach ($res as $key => $item) {
                     $result[0][$key] = $item;
                 }
             }
         }
     }
 }
 /**
  * Checks a status of processes.
  *
  * If the process finished, reads its log files and return the status of finishing and errors/output
  */
 public function checkProcess()
 {
     // TODO: проверить все процессы. Зависшие закрыть принудительно (reject), остальные обработать
     $sortNode = new SortNode(['startedAt' => +1]);
     $query = new Query();
     $query->setSort($sortNode);
     $rows = $this->pidDataStore->query($query);
     foreach ($rows as $row) {
         $pId = intval($row['pId']);
         // checks timeout
         $expireTime = floatval($row['startedAt']) + intval($row['timeout']);
         if ($expireTime <= UTCTime::getUTCTimestamp()) {
             $this->killProcess($pId);
         }
         // checks process existing
         if (!posix_kill($pId, 0)) {
             // The process is finished
             $this->postFinishProcess($row);
             $this->pidDataStore->delete($row['id']);
         }
     }
 }
Exemple #14
0
 public function __construct(DataStoresInterface $cachingDbTable, $cdsId)
 {
     $this->cachingDbTable = $cachingDbTable;
     $query = new Query();
     $query->setQuery(new EqNode($this->cdsIdentifierString, $cdsId));
     $this->items = $this->cachingDbTable->query($query);
     foreach ($this->items as &$item) {
         $item[$this->cachingDbTable->getIdentifier()] = $item[$this->dataIdentifierString];
         unset($item[$this->dataIdentifierString]);
         unset($item[$this->cdsIdentifierString]);
         $item = array_filter($item);
         foreach ($item as $key => $value) {
             switch ($key) {
                 case in_array($key, $this->fieldType['int']):
                     if (is_numeric($value)) {
                         $item[$key] = (int) $value;
                     } else {
                         throw new \Exception('Can\'t parse to int value:' . $value . 'from field: ' . $key);
                     }
                     break;
                 case in_array($key, $this->fieldType['float']):
                     if (is_numeric($value)) {
                         $item[$key] = (double) $value;
                     } else {
                         throw new \Exception('Can\'t parse to float value:' . $value . 'from field: ' . $key);
                     }
                     break;
                 case in_array($key, $this->fieldType['string']):
                     $item[$key] = (string) $value;
                     break;
                 default:
                     throw new \Exception('Type not set for field: ' . $key);
             }
         }
     }
     parent::__construct();
 }
Exemple #15
0
 /**
  * {@inheritdoc}
  *
  * {@inheritdoc}
  */
 public function query(Query $query)
 {
     $limits = $query->getLimit();
     $limit = !$limits ? self::LIMIT_INFINITY : $query->getLimit()->getLimit();
     $offset = !$limits ? 0 : $query->getLimit()->getOffset();
     $sort = $query->getSort();
     $sortFilds = !$sort ? [$this->getIdentifier() => SortNode::SORT_ASC] : $sort->getFields();
     $select = $query->getSelect();
     //What filds will return
     $selectFilds = !$select ? [] : $select->getFields();
     $selectSQL = $this->dbTable->getSql()->select();
     // ***********************   where   ***********************
     $conditionBuilder = $this->conditionBuilder;
     $where = $conditionBuilder($query->getQuery());
     $selectSQL->where($where);
     // ***********************   order   ***********************
     foreach ($sortFilds as $ordKey => $ordVal) {
         if ((int) $ordVal === SortNode::SORT_DESC) {
             $selectSQL->order($ordKey . ' ' . Select::ORDER_DESCENDING);
         } else {
             $selectSQL->order($ordKey . ' ' . Select::ORDER_ASCENDING);
         }
     }
     // *********************  limit, offset   ***********************
     if ($limit != self::LIMIT_INFINITY) {
         $selectSQL->limit($limit);
     }
     if ($offset != 0) {
         $selectSQL->offset($offset);
     }
     // *********************  filds  ***********************
     if (!empty($selectFilds)) {
         $selectSQL->columns($selectFilds);
     }
     // ***********************   return   ***********************
     $rowset = $this->dbTable->selectWith($selectSQL);
     return $rowset->toArray();
 }
Exemple #16
0
 public function testSelectAggregateFunction_Combo_True()
 {
     $this->_initObject();
     $query = new Query();
     $aggregateCount = new AggregateFunctionNode('count', 'id');
     $aggregateMaxId = new AggregateFunctionNode('max', 'id');
     $aggregateMinId = new AggregateFunctionNode('min', 'id');
     $query->setLimit(new Node\LimitNode(2, 1));
     $query->setQuery(new ScalarOperator\EqNode('fString', 'val2'));
     $query->setSelect(new XSelectNode([$aggregateCount, $aggregateMaxId, $aggregateMinId, "anotherId"]));
     $resp = $this->object->query($query);
     $this->assertEquals(1, count($resp));
     $this->assertEquals(2, $resp[0]['id->count']);
     //$this->assertEquals(2, $resp[0]['count(id)']);
     $this->assertEquals(4, $resp[0]['id->max']);
     //$this->assertEquals(4, $resp[0]['max(id)']);
     $this->assertEquals(3, $resp[0]['id->min']);
     //$this->assertEquals(3, $resp[0]['min(id)']);
     $this->assertEquals(40, $resp[0]['anotherId']);
     //$this->assertEquals(40, $resp[0]['anotherId']);
 }
 /**
  * @param Query $query top level query that needs visiting
  *
  * @return void
  */
 public function visitQuery(Query $query)
 {
     if ($query->getSort()) {
         $this->visitSort($query->getSort());
     }
     if ($query->getLimit()) {
         $this->visitLimit($query->getLimit());
     }
 }
 public function test_queryFilterTask()
 {
     /** @var \zaboy\scheduler\Scheduler\Scheduler $scheduler */
     $scheduler = $this->container->get('scheduler');
     $filterData = $scheduler->create(['rql' => 'eq(tp_seconds,0)', 'callback' => function () {
         return 'ky';
     }, 'active' => 1]);
     $id = $filterData['id'];
     $query = new Query();
     $query->setQuery(new EqNode('id', $id));
     $items = $scheduler->query($query);
     $item = array_shift($items);
     $callback = $item['callback'];
     $this->assertEquals('ky', $callback());
 }
 /**
  * Return array of keys or empty array
  *
  * @return array array of keys or empty array
  */
 protected function getKeys()
 {
     $identifier = $this->getIdentifier();
     $query = new Query();
     $selectNode = new Node\SelectNode([$identifier]);
     $query->setSelect($selectNode);
     $queryResult = $this->query($query);
     $keysArray = [];
     foreach ($queryResult as $row) {
         $keysArray[] = $row[$identifier];
     }
     return $keysArray;
 }
 protected function methodPatchWithId(Request $request, Response $response)
 {
     $cdsId = $request->getAttribute('Primary-Key-Value');
     $cdsConf = $this->getCdsConf($cdsId);
     if (empty($cdsConf)) {
         throw new \Exception("this cds id not found");
     }
     if ($cdsConf['query'] !== '') {
         $query = RqlParser::rqlDecode($cdsConf['query']);
     } else {
         $query = new Query();
     }
     $data = $this->getData($cdsConf['script_name'], $query);
     $query = new Query();
     $query->setQuery(new EqNode('cds_id', $cdsId));
     $items = $this->cds->query($query);
     foreach ($items as $item) {
         $this->cds->delete($item['id']);
     }
     foreach ($data as &$item) {
         $item['cds_id'] = $cdsId;
         $item['data_id'] = $item['id'];
         unset($item['id']);
     }
     $this->cds->create($data);
     $this->cdsManagerStore->update(['id' => $cdsConf['id'], 'freshness_date' => (new \DateTime())->format("Y-m-d H:i:s")]);
     $request = $request->withAttribute('CDS-ID', $cdsId);
     $request = $request->withAttribute('Response-Body', ['cdsId' => $cdsId]);
     $response = $response->withStatus(200);
     return array($request, $response);
 }
Exemple #21
0
 protected function setSelectOrder(Select $selectSQL, Query $query)
 {
     $sort = $query->getSort();
     $sortFields = !$sort ? [$this->dbTable->table . '.' . $this->getIdentifier() => SortNode::SORT_ASC] : $sort->getFields();
     /** @var Adapter $adapter */
     $adapter = $this->dbTable->getAdapter();
     $metadata = Factory::createSourceFromAdapter($adapter);
     foreach ($sortFields as $ordKey => $ordVal) {
         if (!preg_match('/[\\w]+\\.[\\w]+/', $ordKey)) {
             $fined = false;
             /** @var DbTable $entity */
             foreach ($this->joinedEntities as $entity) {
                 if (is_object($entity)) {
                     $entityTable = $metadata->getTable($entity->dbTable->table);
                     /** @var Column $column */
                     foreach ($entityTable->getColumns() as $column) {
                         if ($column->getName() == $ordKey) {
                             $ordKey = $entity->dbTable->table . '.' . $ordKey;
                             $fined = true;
                             break;
                         }
                     }
                 }
                 if ($fined) {
                     break;
                 }
             }
             if (!$fined) {
                 $ordKey = $this->dbTable->table . '.' . $ordKey;
             }
         }
         if ((int) $ordVal === SortNode::SORT_DESC) {
             $selectSQL->order($ordKey . ' ' . Select::ORDER_DESCENDING);
         } else {
             $selectSQL->order($ordKey . ' ' . Select::ORDER_ASCENDING);
         }
     }
     return $selectSQL;
 }
Exemple #22
0
 /**
  * @dataProvider provider_Query_Where_Like_False
  */
 public function testQuery_Where_Like_False($globString)
 {
     $this->_initObject();
     $query = new Query();
     $likeNode = new ScalarOperator\LikeNode('fString', new Glob($globString));
     $query->setQuery($likeNode);
     $queryArray = $this->object->query($query);
     $this->assertEquals(0, count($queryArray));
 }
 /**
  *
  * @see Iterator
  * @return array
  */
 public function next()
 {
     $identifier = $this->dataStore->getIdentifier();
     $query = new Query();
     $selectNode = new Node\SelectNode([$identifier]);
     $query->setSelect($selectNode);
     $sortNode = new Node\SortNode([$identifier => 1]);
     $query->setSort($sortNode);
     $limitNode = new Node\LimitNode(1, 0);
     $query->setLimit($limitNode);
     $gtNode = new ScalarOperator\GtNode($identifier, $this->index);
     $query->setQuery($gtNode);
     $queryArray = $this->dataStore->query($query);
     $this->index = $queryArray === [] ? null : $queryArray[0][$identifier];
 }
Exemple #24
0
 /**
  * Determines step size from rql query finding all time labels and find min weight from them
  * @param Query $query
  * @throws TimelineDataStoreException
  */
 public function determineStep(Query $query)
 {
     // TODO: When Query-class will have a method which will build rql-string from rql-object this vethod will require refactoring
     $timeWeights = $this->collectAllTimeWeights($query->getQuery());
     if (!count($timeWeights)) {
         $step = self::DEFAULT_STEP;
     } else {
         $step = min($timeWeights);
     }
     return $step;
 }
 public function test__update_nested_rollback()
 {
     $this->__init();
     $data = $this->object->create(['title' => 'title_1', 'price' => 100, StoreCatalog::PROP_LINKED_URL_TABLE_NAME => [['url' => 'http://google.com', 'alt' => 'Pot1'], ['url' => 'http://google.com2', 'alt' => 'Pot3']]]);
     $data[StoreCatalog::PROP_LINKED_URL_TABLE_NAME] = ['url' => 'http://google.com3', 'alt' => 'Pot4', 'ttt' => 'asd'];
     $data[StoreCatalog::PROP_LINKED_URL_TABLE_NAME] = ['url' => 'http://google.com-1', 'alt' => 'Pot1-1'];
     try {
         $this->object->update($data);
     } catch (DataStoreException $e) {
         $query = new Query();
         $query->setQuery(new AndNode([new EqNode('url', 'http://google.com-1'), new EqNode('alt', 'Pot1-1')]));
         $prop = new Prop(new TableGateway(StoreCatalog::PROP_LINKED_URL_TABLE_NAME, $this->container->get('db')));
         $result = $prop->query($query);
         $this->assertEquals(0, count($result));
         return;
     }
     $this->fail("An expected exception has not been raised.");
 }
Exemple #26
0
 public function test_QueryEq()
 {
     $this->_initObject();
     $query = new Query();
     $eqNode = new ScalarOperator\EqNode('fString', 'val1');
     $query->setQuery($eqNode);
     $this->assertEquals($this->_itemsArrayDelault[0], $this->object->query($query)[0]);
 }
Exemple #27
0
 protected function makeSelect(Query $query)
 {
     $selectNode = $query->getSelect();
     //What fields will be return
     $selectFields = !$selectNode ? [] : $selectNode->getFields();
     if (empty($selectFields)) {
         return '';
     } else {
         $selectString = '&select(';
         foreach ($selectFields as $field) {
             $selectString = $selectString . $field . ',';
         }
         return rtrim($selectString, ',') . ')';
     }
 }
 public function visit(Query $query, SqlBuilder $sqlBuilder)
 {
     if ($query->getSelect() !== null) {
         $this->visitSelectNode($query->getSelect(), $sqlBuilder);
     }
     if ($query->getQuery() !== null) {
         $this->visitQueryNode($query->getQuery(), $sqlBuilder);
     }
     if ($query->getSort() !== null) {
         $this->visitSortNode($query->getSort(), $sqlBuilder);
     }
     if ($query->getLimit() !== null) {
         $this->visitLimitNode($query->getLimit(), $sqlBuilder);
     }
 }
Exemple #29
0
 public function getSqlQuery(Query $query)
 {
     $conditionBuilder = new SqlConditionBuilder($this->dbTable->getAdapter(), $this->dbTable->getTable());
     $selectSQL = $this->dbTable->getSql()->select();
     $selectSQL->where($conditionBuilder($query->getQuery()));
     $selectSQL = $this->setSelectOrder($selectSQL, $query);
     $selectSQL = $this->setSelectLimitOffset($selectSQL, $query);
     $selectSQL = $this->setSelectColumns($selectSQL, $query);
     $selectSQL = $this->setSelectJoin($selectSQL, $query);
     $selectSQL = $this->makeExternalSql($selectSQL);
     //build sql string
     $sql = $this->dbTable->getSql()->buildSqlString($selectSQL);
     //replace double ` char to single.
     $sql = str_replace(["`(", ")`", "``"], ['(', ')', "`"], $sql);
     return $sql;
 }
Exemple #30
0
 /**
  * @param LimitNode $limit
  * @return $this
  */
 public function addLimit(LimitNode $limit)
 {
     $this->query->setLimit($limit);
     return $this;
 }