Add support for query parameters in return limit (#1654)
This commit is contained in:
parent
e7f6a5f4f4
commit
6706ebfa2b
@ -1752,7 +1752,11 @@ antlrcpp::Any CypherMainVisitor::visitReturnBody(MemgraphCypher::ReturnBodyConte
|
||||
body.skip = static_cast<Expression *>(std::any_cast<Expression *>(ctx->skip()->accept(this)));
|
||||
}
|
||||
if (ctx->limit()) {
|
||||
body.limit = static_cast<Expression *>(std::any_cast<Expression *>(ctx->limit()->accept(this)));
|
||||
if (ctx->limit()->expression()) {
|
||||
body.limit = std::any_cast<Expression *>(ctx->limit()->accept(this));
|
||||
} else {
|
||||
body.limit = std::any_cast<ParameterLookup *>(ctx->limit()->accept(this));
|
||||
}
|
||||
}
|
||||
std::tie(body.all_identifiers, body.named_expressions) =
|
||||
std::any_cast<std::pair<bool, std::vector<NamedExpression *>>>(ctx->returnItems()->accept(this));
|
||||
|
@ -143,7 +143,7 @@ order : ORDER BY sortItem ( ',' sortItem )* ;
|
||||
|
||||
skip : L_SKIP expression ;
|
||||
|
||||
limit : LIMIT expression ;
|
||||
limit : LIMIT ( expression | parameter ) ;
|
||||
|
||||
sortItem : expression ( ASCENDING | ASC | DESCENDING | DESC )? ;
|
||||
|
||||
|
@ -153,3 +153,20 @@ Feature: Parameters
|
||||
Then the result should be:
|
||||
| a |
|
||||
| (:Label1 {x: 10}) |
|
||||
|
||||
Scenario: Parameters for limit in return returnBody
|
||||
Given an empty graph
|
||||
And having executed:
|
||||
"""
|
||||
FOREACH (id IN range(1, 10) | CREATE (:Node {id: id}))
|
||||
"""
|
||||
And parameters are:
|
||||
| limit | 2 |
|
||||
When executing query:
|
||||
"""
|
||||
MATCH (n) RETURN n LIMIT $limit
|
||||
"""
|
||||
Then the result should be:
|
||||
| n |
|
||||
| (:Node {id: 1}) |
|
||||
| (:Node {id: 2}) |
|
||||
|
Loading…
Reference in New Issue
Block a user