@entity-access/entity-access 1.0.301 → 1.0.302

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -215,6 +215,8 @@ export default class ArrowToExpression extends BabelVisitor<Expression> {
215
215
  // we need to sanitize callee
216
216
  this.sanitize(callee);
217
217
 
218
+ // change Sql.coll. with arrow functions to move it inside
219
+
218
220
  return CallExpression.create({
219
221
  callee: callee ? this.visit(callee) : void 0,
220
222
  arguments: args ? args.map((x) => this.visit(x)) : []
@@ -302,6 +304,11 @@ export default class ArrowToExpression extends BabelVisitor<Expression> {
302
304
  throw new Error(`Unknown identifier ${name}`);
303
305
  }
304
306
  return;
307
+ case "CallExpression":
308
+ for (const iterator of node.arguments) {
309
+ this.visit(iterator as bpe.Expression);
310
+ }
311
+ return;
305
312
  case "MemberExpression":
306
313
  case "OptionalMemberExpression":
307
314
  return this.sanitize(node.object);
@@ -0,0 +1,38 @@
1
+ import assert from "assert";
2
+ import { TestConfig } from "../../TestConfig.js";
3
+ import { createContext, headPhoneCategory } from "../../model/createContext.js";
4
+ import Sql from "../../../sql/Sql.js";
5
+
6
+ export default async function(this: TestConfig) {
7
+
8
+ if (!this.db) {
9
+ return;
10
+ }
11
+
12
+ const context = await createContext(this.driver);
13
+
14
+ let report;
15
+ // report = await context.users.all()
16
+ // .where({}, (p) => (x) => x.orders.some((oi) => oi.customerID > 0))
17
+ // .map({}, (p) => (x) => ({
18
+ // total: Sql.coll.sum(x.orders.map((o) => Sql.coll.sum(o.orderItems.map((oi) => oi.amount))))
19
+ // })
20
+ // )
21
+ // .trace(console.log)
22
+ // .first();
23
+
24
+ // assert.notEqual(null, report);
25
+
26
+ report = await context.users.all()
27
+ .where({}, (p) => (x) => x.orders.some((oi) => oi.customerID > 0))
28
+ .map({}, (p) => (x) => ({
29
+ total: Sql.coll.sum(x.orders
30
+ .filter((o) => o.status === "pending")
31
+ .map((o) => Sql.coll.sum(o.orderItems.map((oi) => oi.amount))))
32
+ })
33
+ )
34
+ .trace(console.log)
35
+ .first();
36
+
37
+ assert.notEqual(null, report);
38
+ }
@@ -342,6 +342,9 @@ export class Order {
342
342
  @Column({ dataType: "Char", length: 200, nullable: true})
343
343
  public purchaseOrder: string;
344
344
 
345
+ @Column({ dataType: "Char", length: 20, default: () => "pending"})
346
+ public status: string;
347
+
345
348
  public orderItems: OrderItem[];
346
349
 
347
350
  public customer: User;