Skip to content

Commit fa74345

Browse files
committed
Remove second parameter of listComprehension
1 parent 4ef105e commit fa74345

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

.changeset/clean-items-greet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@neo4j/cypher-builder": major
3+
---
4+
5+
Remove second parameter of `ListComprehension` in favor of `.in`

src/expressions/list/ListComprehension.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("List comprehension", () => {
2525
const variable = new Cypher.Variable();
2626
const exprVariable = new Cypher.Param([1, 2, 5]);
2727

28-
const listComprehension = new Cypher.ListComprehension(variable, exprVariable);
28+
const listComprehension = new Cypher.ListComprehension(variable).in(exprVariable);
2929

3030
const queryResult = new TestClause(listComprehension).build();
3131

@@ -47,7 +47,7 @@ describe("List comprehension", () => {
4747
const exprVariable = new Cypher.Param([1, 2, 5]);
4848
const andExpr = Cypher.eq(variable, new Cypher.Param(5));
4949

50-
const listComprehension = new Cypher.ListComprehension(variable, exprVariable).where(andExpr);
50+
const listComprehension = new Cypher.ListComprehension(variable).in(exprVariable).where(andExpr);
5151

5252
const queryResult = new TestClause(listComprehension).build();
5353

@@ -96,7 +96,7 @@ describe("List comprehension", () => {
9696
const exprVariable = new Cypher.Param([1, 2, 5]);
9797

9898
expect(() => {
99-
new Cypher.ListComprehension(variable, exprVariable).in(exprVariable);
99+
new Cypher.ListComprehension(variable).in(exprVariable).in(exprVariable);
100100
}).toThrow("Cannot set 2 lists in list comprehension IN");
101101
});
102102

src/expressions/list/ListComprehension.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ export class ListComprehension extends CypherASTNode {
3838
private listExpr: Expr | undefined;
3939
private mapExpr: Expr | undefined; // Expression for list mapping
4040

41-
constructor(variable: Variable, listExpr?: Expr) {
41+
constructor(variable: Variable) {
4242
super();
4343
this.variable = variable;
44-
this.listExpr = listExpr;
4544
}
4645

4746
public in(listExpr: Expr): this {

0 commit comments

Comments
 (0)