Skip to content

Commit d64a66a

Browse files
committed
Added support for parameter less expression
1 parent 08a5162 commit d64a66a

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/query/parser/ArrowToExpression.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,23 @@ export default class ArrowToExpression extends BabelVisitor<Expression> {
6565
}
6666

6767
const firstTarget = body.params[0];
68-
if (firstTarget.type !== "Identifier") {
69-
throw new Error("Expecting an identifier");
68+
69+
let name = "____x";
70+
71+
if (firstTarget) {
72+
73+
if (firstTarget.type !== "Identifier") {
74+
throw new Error("Expecting an identifier");
75+
}
76+
name = firstTarget.name;
7077
}
7178

72-
target ??= ParameterExpression.create({ name: firstTarget.name});
79+
80+
target ??= ParameterExpression.create({ name});
7381

7482
body = body.body;
7583

76-
const visitor = new this(params, target, firstTarget.name);
84+
const visitor = new this(params, target, name);
7785
return {
7886
params,
7987
target,

src/tests/db-tests/tests/update-items.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default async function(this: TestConfig) {
2121
await context.products
2222
.where(void 0, (p) => (x) => x.productID > 1)
2323
// .trace(console.log)
24-
.update(void 0, (p) => (x) => ({
24+
.update(void 0, () => () => ({
2525
productDescription: "updated"
2626
}));
2727

0 commit comments

Comments
 (0)