@rocicorp/zero 0.20.2025051501 → 0.20.2025051502
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.
- package/out/{chunk-P3G5C3ZW.js → chunk-IKN2MNWU.js} +2 -2
- package/out/{chunk-ILWAR46C.js → chunk-MIYN75UK.js} +203 -274
- package/out/chunk-MIYN75UK.js.map +7 -0
- package/out/{chunk-A64L6YZK.js → chunk-MVAGDDJ4.js} +5 -5
- package/out/{inspector-B2ZMZ35Y.js → inspector-2QLL7CGJ.js} +3 -3
- package/out/otel/src/log-options.d.ts +0 -12
- package/out/otel/src/log-options.d.ts.map +1 -1
- package/out/otel/src/log-options.js +0 -21
- package/out/otel/src/log-options.js.map +1 -1
- package/out/react.js +1 -1
- package/out/solid.js +3 -3
- package/out/zero/src/zero-cache-dev.js +5 -1
- package/out/zero/src/zero-cache-dev.js.map +1 -1
- package/out/zero-cache/src/auth/read-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/read-authorizer.js +2 -2
- package/out/zero-cache/src/auth/read-authorizer.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js +2 -2
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +0 -24
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/scripts/permissions.d.ts +0 -12
- package/out/zero-cache/src/scripts/permissions.d.ts.map +1 -1
- package/out/zero-cache/src/server/logging.d.ts.map +1 -1
- package/out/zero-cache/src/server/logging.js +2 -2
- package/out/zero-cache/src/server/logging.js.map +1 -1
- package/out/zero-cache/src/server/otel-log-sink.d.ts +1 -2
- package/out/zero-cache/src/server/otel-log-sink.d.ts.map +1 -1
- package/out/zero-cache/src/server/otel-log-sink.js +4 -5
- package/out/zero-cache/src/server/otel-log-sink.js.map +1 -1
- package/out/zero-cache/src/server/otel-start.d.ts +1 -6
- package/out/zero-cache/src/server/otel-start.d.ts.map +1 -1
- package/out/zero-cache/src/server/otel-start.js +54 -45
- package/out/zero-cache/src/server/otel-start.js.map +1 -1
- package/out/zero-cache/src/server/syncer.js +2 -2
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero.js +3 -3
- package/out/zql/src/builder/builder.d.ts.map +1 -1
- package/out/zql/src/builder/builder.js +19 -38
- package/out/zql/src/builder/builder.js.map +1 -1
- package/out/zql/src/builder/filter.d.ts.map +1 -1
- package/out/zql/src/builder/filter.js +12 -30
- package/out/zql/src/builder/filter.js.map +1 -1
- package/out/zql/src/query/expression.d.ts +2 -1
- package/out/zql/src/query/expression.d.ts.map +1 -1
- package/out/zql/src/query/expression.js +19 -0
- package/out/zql/src/query/expression.js.map +1 -1
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +2 -3
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/package.json +2 -1
- package/out/chunk-ILWAR46C.js.map +0 -7
- package/out/otel/src/noop-metric-exporter.d.ts +0 -8
- package/out/otel/src/noop-metric-exporter.d.ts.map +0 -1
- package/out/otel/src/noop-metric-exporter.js +0 -11
- package/out/otel/src/noop-metric-exporter.js.map +0 -1
- package/out/otel/src/noop-span-exporter.d.ts +0 -8
- package/out/otel/src/noop-span-exporter.d.ts.map +0 -1
- package/out/otel/src/noop-span-exporter.js +0 -14
- package/out/otel/src/noop-span-exporter.js.map +0 -1
- package/out/zql/src/query/dnf.d.ts +0 -10
- package/out/zql/src/query/dnf.d.ts.map +0 -1
- package/out/zql/src/query/dnf.js +0 -57
- package/out/zql/src/query/dnf.js.map +0 -1
- /package/out/{chunk-P3G5C3ZW.js.map → chunk-IKN2MNWU.js.map} +0 -0
- /package/out/{chunk-A64L6YZK.js.map → chunk-MVAGDDJ4.js.map} +0 -0
- /package/out/{inspector-B2ZMZ35Y.js.map → inspector-2QLL7CGJ.js.map} +0 -0
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
readonlyObject,
|
|
14
14
|
readonlyRecord,
|
|
15
15
|
valita_exports
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-MIYN75UK.js";
|
|
17
17
|
import {
|
|
18
18
|
assert,
|
|
19
19
|
assertArray,
|
|
@@ -2889,4 +2889,4 @@ export {
|
|
|
2889
2889
|
toPrimaryKeyString,
|
|
2890
2890
|
sourceNameFromKey
|
|
2891
2891
|
};
|
|
2892
|
-
//# sourceMappingURL=chunk-
|
|
2892
|
+
//# sourceMappingURL=chunk-IKN2MNWU.js.map
|
|
@@ -2368,6 +2368,175 @@ function makePartitionKeyComparator(partitionKey) {
|
|
|
2368
2368
|
};
|
|
2369
2369
|
}
|
|
2370
2370
|
|
|
2371
|
+
// ../zql/src/query/expression.ts
|
|
2372
|
+
var ExpressionBuilder = class {
|
|
2373
|
+
#exists;
|
|
2374
|
+
constructor(exists) {
|
|
2375
|
+
this.#exists = exists;
|
|
2376
|
+
this.exists = this.exists.bind(this);
|
|
2377
|
+
}
|
|
2378
|
+
get eb() {
|
|
2379
|
+
return this;
|
|
2380
|
+
}
|
|
2381
|
+
cmp(field, opOrValue, value) {
|
|
2382
|
+
return cmp(field, opOrValue, value);
|
|
2383
|
+
}
|
|
2384
|
+
cmpLit(left, op, right) {
|
|
2385
|
+
return {
|
|
2386
|
+
type: "simple",
|
|
2387
|
+
left: isParameterReference(left) ? left[toStaticParam]() : { type: "literal", value: left },
|
|
2388
|
+
right: isParameterReference(right) ? right[toStaticParam]() : { type: "literal", value: right },
|
|
2389
|
+
op
|
|
2390
|
+
};
|
|
2391
|
+
}
|
|
2392
|
+
and = and;
|
|
2393
|
+
or = or;
|
|
2394
|
+
not = not;
|
|
2395
|
+
exists = (relationship, cb) => this.#exists(relationship, cb);
|
|
2396
|
+
};
|
|
2397
|
+
function and(...conditions) {
|
|
2398
|
+
const expressions = filterTrue(filterUndefined(conditions));
|
|
2399
|
+
if (expressions.length === 1) {
|
|
2400
|
+
return expressions[0];
|
|
2401
|
+
}
|
|
2402
|
+
if (expressions.some(isAlwaysFalse)) {
|
|
2403
|
+
return FALSE;
|
|
2404
|
+
}
|
|
2405
|
+
return { type: "and", conditions: expressions };
|
|
2406
|
+
}
|
|
2407
|
+
function or(...conditions) {
|
|
2408
|
+
const expressions = filterFalse(filterUndefined(conditions));
|
|
2409
|
+
if (expressions.length === 1) {
|
|
2410
|
+
return expressions[0];
|
|
2411
|
+
}
|
|
2412
|
+
if (expressions.some(isAlwaysTrue)) {
|
|
2413
|
+
return TRUE;
|
|
2414
|
+
}
|
|
2415
|
+
return { type: "or", conditions: expressions };
|
|
2416
|
+
}
|
|
2417
|
+
function not(expression) {
|
|
2418
|
+
switch (expression.type) {
|
|
2419
|
+
case "and":
|
|
2420
|
+
return {
|
|
2421
|
+
type: "or",
|
|
2422
|
+
conditions: expression.conditions.map(not)
|
|
2423
|
+
};
|
|
2424
|
+
case "or":
|
|
2425
|
+
return {
|
|
2426
|
+
type: "and",
|
|
2427
|
+
conditions: expression.conditions.map(not)
|
|
2428
|
+
};
|
|
2429
|
+
case "correlatedSubquery":
|
|
2430
|
+
return {
|
|
2431
|
+
type: "correlatedSubquery",
|
|
2432
|
+
related: expression.related,
|
|
2433
|
+
op: negateOperator(expression.op)
|
|
2434
|
+
};
|
|
2435
|
+
case "simple":
|
|
2436
|
+
return {
|
|
2437
|
+
type: "simple",
|
|
2438
|
+
op: negateOperator(expression.op),
|
|
2439
|
+
left: expression.left,
|
|
2440
|
+
right: expression.right
|
|
2441
|
+
};
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
function cmp(field, opOrValue, value) {
|
|
2445
|
+
let op;
|
|
2446
|
+
if (value === void 0) {
|
|
2447
|
+
value = opOrValue;
|
|
2448
|
+
op = "=";
|
|
2449
|
+
} else {
|
|
2450
|
+
op = opOrValue;
|
|
2451
|
+
}
|
|
2452
|
+
return {
|
|
2453
|
+
type: "simple",
|
|
2454
|
+
left: { type: "column", name: field },
|
|
2455
|
+
right: isParameterReference(value) ? value[toStaticParam]() : { type: "literal", value },
|
|
2456
|
+
op
|
|
2457
|
+
};
|
|
2458
|
+
}
|
|
2459
|
+
function isParameterReference(value) {
|
|
2460
|
+
return value !== null && typeof value === "object" && value[toStaticParam];
|
|
2461
|
+
}
|
|
2462
|
+
var TRUE = {
|
|
2463
|
+
type: "and",
|
|
2464
|
+
conditions: []
|
|
2465
|
+
};
|
|
2466
|
+
var FALSE = {
|
|
2467
|
+
type: "or",
|
|
2468
|
+
conditions: []
|
|
2469
|
+
};
|
|
2470
|
+
function isAlwaysTrue(condition) {
|
|
2471
|
+
return condition.type === "and" && condition.conditions.length === 0;
|
|
2472
|
+
}
|
|
2473
|
+
function isAlwaysFalse(condition) {
|
|
2474
|
+
return condition.type === "or" && condition.conditions.length === 0;
|
|
2475
|
+
}
|
|
2476
|
+
function simplifyCondition(c) {
|
|
2477
|
+
if (c.type === "simple" || c.type === "correlatedSubquery") {
|
|
2478
|
+
return c;
|
|
2479
|
+
}
|
|
2480
|
+
if (c.conditions.length === 1) {
|
|
2481
|
+
return simplifyCondition(c.conditions[0]);
|
|
2482
|
+
}
|
|
2483
|
+
const conditions = flatten(c.type, c.conditions.map(simplifyCondition));
|
|
2484
|
+
if (c.type === "and" && conditions.some(isAlwaysFalse)) {
|
|
2485
|
+
return FALSE;
|
|
2486
|
+
}
|
|
2487
|
+
if (c.type === "or" && conditions.some(isAlwaysTrue)) {
|
|
2488
|
+
return TRUE;
|
|
2489
|
+
}
|
|
2490
|
+
return {
|
|
2491
|
+
type: c.type,
|
|
2492
|
+
conditions
|
|
2493
|
+
};
|
|
2494
|
+
}
|
|
2495
|
+
function flatten(type, conditions) {
|
|
2496
|
+
const flattened2 = [];
|
|
2497
|
+
for (const c of conditions) {
|
|
2498
|
+
if (c.type === type) {
|
|
2499
|
+
flattened2.push(...c.conditions);
|
|
2500
|
+
} else {
|
|
2501
|
+
flattened2.push(c);
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
return flattened2;
|
|
2505
|
+
}
|
|
2506
|
+
var negateSimpleOperatorMap = {
|
|
2507
|
+
["="]: "!=",
|
|
2508
|
+
["!="]: "=",
|
|
2509
|
+
["<"]: ">=",
|
|
2510
|
+
[">"]: "<=",
|
|
2511
|
+
[">="]: "<",
|
|
2512
|
+
["<="]: ">",
|
|
2513
|
+
["IN"]: "NOT IN",
|
|
2514
|
+
["NOT IN"]: "IN",
|
|
2515
|
+
["LIKE"]: "NOT LIKE",
|
|
2516
|
+
["NOT LIKE"]: "LIKE",
|
|
2517
|
+
["ILIKE"]: "NOT ILIKE",
|
|
2518
|
+
["NOT ILIKE"]: "ILIKE",
|
|
2519
|
+
["IS"]: "IS NOT",
|
|
2520
|
+
["IS NOT"]: "IS"
|
|
2521
|
+
};
|
|
2522
|
+
var negateOperatorMap = {
|
|
2523
|
+
...negateSimpleOperatorMap,
|
|
2524
|
+
["EXISTS"]: "NOT EXISTS",
|
|
2525
|
+
["NOT EXISTS"]: "EXISTS"
|
|
2526
|
+
};
|
|
2527
|
+
function negateOperator(op) {
|
|
2528
|
+
return must(negateOperatorMap[op]);
|
|
2529
|
+
}
|
|
2530
|
+
function filterUndefined(array3) {
|
|
2531
|
+
return array3.filter((e) => e !== void 0);
|
|
2532
|
+
}
|
|
2533
|
+
function filterTrue(conditions) {
|
|
2534
|
+
return conditions.filter((c) => !isAlwaysTrue(c));
|
|
2535
|
+
}
|
|
2536
|
+
function filterFalse(conditions) {
|
|
2537
|
+
return conditions.filter((c) => !isAlwaysFalse(c));
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2371
2540
|
// ../zql/src/builder/like.ts
|
|
2372
2541
|
function getLikePredicate(pattern, flags) {
|
|
2373
2542
|
const op = getLikeOp(String(pattern), flags);
|
|
@@ -2503,11 +2672,11 @@ function createPredicateImpl(rhs, operator) {
|
|
|
2503
2672
|
case "LIKE":
|
|
2504
2673
|
return getLikePredicate(rhs, "");
|
|
2505
2674
|
case "NOT LIKE":
|
|
2506
|
-
return
|
|
2675
|
+
return not2(getLikePredicate(rhs, ""));
|
|
2507
2676
|
case "ILIKE":
|
|
2508
2677
|
return getLikePredicate(rhs, "i");
|
|
2509
2678
|
case "NOT ILIKE":
|
|
2510
|
-
return
|
|
2679
|
+
return not2(getLikePredicate(rhs, "i"));
|
|
2511
2680
|
case "IN": {
|
|
2512
2681
|
assert(Array.isArray(rhs));
|
|
2513
2682
|
const set = new Set(rhs);
|
|
@@ -2523,7 +2692,7 @@ function createPredicateImpl(rhs, operator) {
|
|
|
2523
2692
|
throw new Error(`Unexpected operator: ${operator}`);
|
|
2524
2693
|
}
|
|
2525
2694
|
}
|
|
2526
|
-
function
|
|
2695
|
+
function not2(f) {
|
|
2527
2696
|
return (lhs) => !f(lhs);
|
|
2528
2697
|
}
|
|
2529
2698
|
function transformFilters(filters) {
|
|
@@ -2535,46 +2704,25 @@ function transformFilters(filters) {
|
|
|
2535
2704
|
return { filters, conditionsRemoved: false };
|
|
2536
2705
|
case "correlatedSubquery":
|
|
2537
2706
|
return { filters: void 0, conditionsRemoved: true };
|
|
2538
|
-
case "and":
|
|
2539
|
-
const transformedConditions = [];
|
|
2540
|
-
for (const cond of filters.conditions) {
|
|
2541
|
-
assert(cond.type === "simple" || cond.type === "correlatedSubquery");
|
|
2542
|
-
if (cond.type === "simple") {
|
|
2543
|
-
transformedConditions.push(cond);
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
const conditionsRemoved = transformedConditions.length !== filters.conditions.length;
|
|
2547
|
-
if (transformedConditions.length === 0) {
|
|
2548
|
-
return { filters: void 0, conditionsRemoved };
|
|
2549
|
-
}
|
|
2550
|
-
if (transformedConditions.length === 1) {
|
|
2551
|
-
return {
|
|
2552
|
-
filters: transformedConditions[0],
|
|
2553
|
-
conditionsRemoved
|
|
2554
|
-
};
|
|
2555
|
-
}
|
|
2556
|
-
return {
|
|
2557
|
-
filters: {
|
|
2558
|
-
type: "and",
|
|
2559
|
-
conditions: transformedConditions
|
|
2560
|
-
},
|
|
2561
|
-
conditionsRemoved
|
|
2562
|
-
};
|
|
2563
|
-
}
|
|
2707
|
+
case "and":
|
|
2564
2708
|
case "or": {
|
|
2565
2709
|
const transformedConditions = [];
|
|
2566
2710
|
let conditionsRemoved = false;
|
|
2567
2711
|
for (const cond of filters.conditions) {
|
|
2568
|
-
assert(cond.type !== "or");
|
|
2569
2712
|
const transformed = transformFilters(cond);
|
|
2570
|
-
if (transformed.filters === void 0) {
|
|
2713
|
+
if (transformed.filters === void 0 && filters.type === "or") {
|
|
2571
2714
|
return { filters: void 0, conditionsRemoved: true };
|
|
2572
2715
|
}
|
|
2573
2716
|
conditionsRemoved = conditionsRemoved || transformed.conditionsRemoved;
|
|
2574
|
-
|
|
2717
|
+
if (transformed.filters) {
|
|
2718
|
+
transformedConditions.push(transformed.filters);
|
|
2719
|
+
}
|
|
2575
2720
|
}
|
|
2576
2721
|
return {
|
|
2577
|
-
filters: {
|
|
2722
|
+
filters: simplifyCondition({
|
|
2723
|
+
type: filters.type,
|
|
2724
|
+
conditions: transformedConditions
|
|
2725
|
+
}),
|
|
2578
2726
|
conditionsRemoved
|
|
2579
2727
|
};
|
|
2580
2728
|
}
|
|
@@ -2601,7 +2749,9 @@ function buildPipelineInternal(ast, delegate, name, partitionKey) {
|
|
|
2601
2749
|
ast.where
|
|
2602
2750
|
);
|
|
2603
2751
|
const splitEditKeys = partitionKey ? new Set(partitionKey) : /* @__PURE__ */ new Set();
|
|
2752
|
+
const aliases = /* @__PURE__ */ new Set();
|
|
2604
2753
|
for (const csq of csqsFromCondition) {
|
|
2754
|
+
aliases.add(csq.subquery.alias || "");
|
|
2605
2755
|
for (const key of csq.correlation.parentField) {
|
|
2606
2756
|
splitEditKeys.add(key);
|
|
2607
2757
|
}
|
|
@@ -2708,11 +2858,10 @@ function isNotAndDoesNotContainSubquery(condition) {
|
|
|
2708
2858
|
if (condition.type === "correlatedSubquery") {
|
|
2709
2859
|
return false;
|
|
2710
2860
|
}
|
|
2711
|
-
if (condition.type === "
|
|
2712
|
-
return
|
|
2861
|
+
if (condition.type === "simple") {
|
|
2862
|
+
return true;
|
|
2713
2863
|
}
|
|
2714
|
-
|
|
2715
|
-
return true;
|
|
2864
|
+
return condition.conditions.every(isNotAndDoesNotContainSubquery);
|
|
2716
2865
|
}
|
|
2717
2866
|
function applySimpleCondition(input, condition) {
|
|
2718
2867
|
return new Filter(input, createPredicate(condition));
|
|
@@ -2814,43 +2963,26 @@ function uniquifyCorrelatedSubqueryConditionAliases(ast) {
|
|
|
2814
2963
|
}
|
|
2815
2964
|
}
|
|
2816
2965
|
});
|
|
2817
|
-
const
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2966
|
+
const uniquify = (cond) => {
|
|
2967
|
+
if (cond.type === "simple") {
|
|
2968
|
+
return cond;
|
|
2969
|
+
} else if (cond.type === "correlatedSubquery") {
|
|
2970
|
+
return uniquifyCorrelatedSubquery(cond);
|
|
2971
|
+
}
|
|
2972
|
+
const conditions = [];
|
|
2973
|
+
for (const c of cond.conditions) {
|
|
2974
|
+
conditions.push(uniquify(c));
|
|
2825
2975
|
}
|
|
2826
2976
|
return {
|
|
2827
|
-
|
|
2828
|
-
conditions
|
|
2977
|
+
type: cond.type,
|
|
2978
|
+
conditions
|
|
2829
2979
|
};
|
|
2830
2980
|
};
|
|
2831
|
-
|
|
2832
|
-
return {
|
|
2833
|
-
...ast,
|
|
2834
|
-
where: uniquifyAnd(where)
|
|
2835
|
-
};
|
|
2836
|
-
}
|
|
2837
|
-
const conds = [];
|
|
2838
|
-
for (const cond of where.conditions) {
|
|
2839
|
-
if (cond.type === "simple") {
|
|
2840
|
-
conds.push(cond);
|
|
2841
|
-
} else if (cond.type === "correlatedSubquery") {
|
|
2842
|
-
conds.push(uniquifyCorrelatedSubquery(cond));
|
|
2843
|
-
} else if (cond.type === "and") {
|
|
2844
|
-
conds.push(uniquifyAnd(cond));
|
|
2845
|
-
}
|
|
2846
|
-
}
|
|
2847
|
-
return {
|
|
2981
|
+
const result = {
|
|
2848
2982
|
...ast,
|
|
2849
|
-
where:
|
|
2850
|
-
...where,
|
|
2851
|
-
conditions: conds
|
|
2852
|
-
}
|
|
2983
|
+
where: uniquify(where)
|
|
2853
2984
|
};
|
|
2985
|
+
return result;
|
|
2854
2986
|
}
|
|
2855
2987
|
|
|
2856
2988
|
// ../zql/src/ivm/array-view.ts
|
|
@@ -2963,209 +3095,6 @@ function assertNoNotExists(condition) {
|
|
|
2963
3095
|
}
|
|
2964
3096
|
}
|
|
2965
3097
|
|
|
2966
|
-
// ../zql/src/query/expression.ts
|
|
2967
|
-
var ExpressionBuilder = class {
|
|
2968
|
-
#exists;
|
|
2969
|
-
constructor(exists) {
|
|
2970
|
-
this.#exists = exists;
|
|
2971
|
-
this.exists = this.exists.bind(this);
|
|
2972
|
-
}
|
|
2973
|
-
get eb() {
|
|
2974
|
-
return this;
|
|
2975
|
-
}
|
|
2976
|
-
cmp(field, opOrValue, value) {
|
|
2977
|
-
return cmp(field, opOrValue, value);
|
|
2978
|
-
}
|
|
2979
|
-
cmpLit(left, op, right) {
|
|
2980
|
-
return {
|
|
2981
|
-
type: "simple",
|
|
2982
|
-
left: isParameterReference(left) ? left[toStaticParam]() : { type: "literal", value: left },
|
|
2983
|
-
right: isParameterReference(right) ? right[toStaticParam]() : { type: "literal", value: right },
|
|
2984
|
-
op
|
|
2985
|
-
};
|
|
2986
|
-
}
|
|
2987
|
-
and = and;
|
|
2988
|
-
or = or;
|
|
2989
|
-
not = not2;
|
|
2990
|
-
exists = (relationship, cb) => this.#exists(relationship, cb);
|
|
2991
|
-
};
|
|
2992
|
-
function and(...conditions) {
|
|
2993
|
-
const expressions = filterTrue(filterUndefined(conditions));
|
|
2994
|
-
if (expressions.length === 1) {
|
|
2995
|
-
return expressions[0];
|
|
2996
|
-
}
|
|
2997
|
-
if (expressions.some(isAlwaysFalse)) {
|
|
2998
|
-
return FALSE;
|
|
2999
|
-
}
|
|
3000
|
-
return { type: "and", conditions: expressions };
|
|
3001
|
-
}
|
|
3002
|
-
function or(...conditions) {
|
|
3003
|
-
const expressions = filterFalse(filterUndefined(conditions));
|
|
3004
|
-
if (expressions.length === 1) {
|
|
3005
|
-
return expressions[0];
|
|
3006
|
-
}
|
|
3007
|
-
if (expressions.some(isAlwaysTrue)) {
|
|
3008
|
-
return TRUE;
|
|
3009
|
-
}
|
|
3010
|
-
return { type: "or", conditions: expressions };
|
|
3011
|
-
}
|
|
3012
|
-
function not2(expression) {
|
|
3013
|
-
switch (expression.type) {
|
|
3014
|
-
case "and":
|
|
3015
|
-
return {
|
|
3016
|
-
type: "or",
|
|
3017
|
-
conditions: expression.conditions.map(not2)
|
|
3018
|
-
};
|
|
3019
|
-
case "or":
|
|
3020
|
-
return {
|
|
3021
|
-
type: "and",
|
|
3022
|
-
conditions: expression.conditions.map(not2)
|
|
3023
|
-
};
|
|
3024
|
-
case "correlatedSubquery":
|
|
3025
|
-
return {
|
|
3026
|
-
type: "correlatedSubquery",
|
|
3027
|
-
related: expression.related,
|
|
3028
|
-
op: negateOperator(expression.op)
|
|
3029
|
-
};
|
|
3030
|
-
case "simple":
|
|
3031
|
-
return {
|
|
3032
|
-
type: "simple",
|
|
3033
|
-
op: negateOperator(expression.op),
|
|
3034
|
-
left: expression.left,
|
|
3035
|
-
right: expression.right
|
|
3036
|
-
};
|
|
3037
|
-
}
|
|
3038
|
-
}
|
|
3039
|
-
function cmp(field, opOrValue, value) {
|
|
3040
|
-
let op;
|
|
3041
|
-
if (value === void 0) {
|
|
3042
|
-
value = opOrValue;
|
|
3043
|
-
op = "=";
|
|
3044
|
-
} else {
|
|
3045
|
-
op = opOrValue;
|
|
3046
|
-
}
|
|
3047
|
-
return {
|
|
3048
|
-
type: "simple",
|
|
3049
|
-
left: { type: "column", name: field },
|
|
3050
|
-
right: isParameterReference(value) ? value[toStaticParam]() : { type: "literal", value },
|
|
3051
|
-
op
|
|
3052
|
-
};
|
|
3053
|
-
}
|
|
3054
|
-
function isParameterReference(value) {
|
|
3055
|
-
return value !== null && typeof value === "object" && value[toStaticParam];
|
|
3056
|
-
}
|
|
3057
|
-
var TRUE = {
|
|
3058
|
-
type: "and",
|
|
3059
|
-
conditions: []
|
|
3060
|
-
};
|
|
3061
|
-
var FALSE = {
|
|
3062
|
-
type: "or",
|
|
3063
|
-
conditions: []
|
|
3064
|
-
};
|
|
3065
|
-
function isAlwaysTrue(condition) {
|
|
3066
|
-
return condition.type === "and" && condition.conditions.length === 0;
|
|
3067
|
-
}
|
|
3068
|
-
function isAlwaysFalse(condition) {
|
|
3069
|
-
return condition.type === "or" && condition.conditions.length === 0;
|
|
3070
|
-
}
|
|
3071
|
-
function flatten(type, conditions) {
|
|
3072
|
-
const flattened2 = [];
|
|
3073
|
-
for (const c of conditions) {
|
|
3074
|
-
if (c.type === type) {
|
|
3075
|
-
flattened2.push(...c.conditions);
|
|
3076
|
-
} else {
|
|
3077
|
-
flattened2.push(c);
|
|
3078
|
-
}
|
|
3079
|
-
}
|
|
3080
|
-
return flattened2;
|
|
3081
|
-
}
|
|
3082
|
-
var negateSimpleOperatorMap = {
|
|
3083
|
-
["="]: "!=",
|
|
3084
|
-
["!="]: "=",
|
|
3085
|
-
["<"]: ">=",
|
|
3086
|
-
[">"]: "<=",
|
|
3087
|
-
[">="]: "<",
|
|
3088
|
-
["<="]: ">",
|
|
3089
|
-
["IN"]: "NOT IN",
|
|
3090
|
-
["NOT IN"]: "IN",
|
|
3091
|
-
["LIKE"]: "NOT LIKE",
|
|
3092
|
-
["NOT LIKE"]: "LIKE",
|
|
3093
|
-
["ILIKE"]: "NOT ILIKE",
|
|
3094
|
-
["NOT ILIKE"]: "ILIKE",
|
|
3095
|
-
["IS"]: "IS NOT",
|
|
3096
|
-
["IS NOT"]: "IS"
|
|
3097
|
-
};
|
|
3098
|
-
var negateOperatorMap = {
|
|
3099
|
-
...negateSimpleOperatorMap,
|
|
3100
|
-
["EXISTS"]: "NOT EXISTS",
|
|
3101
|
-
["NOT EXISTS"]: "EXISTS"
|
|
3102
|
-
};
|
|
3103
|
-
function negateOperator(op) {
|
|
3104
|
-
return must(negateOperatorMap[op]);
|
|
3105
|
-
}
|
|
3106
|
-
function filterUndefined(array3) {
|
|
3107
|
-
return array3.filter((e) => e !== void 0);
|
|
3108
|
-
}
|
|
3109
|
-
function filterTrue(conditions) {
|
|
3110
|
-
return conditions.filter((c) => !isAlwaysTrue(c));
|
|
3111
|
-
}
|
|
3112
|
-
function filterFalse(conditions) {
|
|
3113
|
-
return conditions.filter((c) => !isAlwaysFalse(c));
|
|
3114
|
-
}
|
|
3115
|
-
|
|
3116
|
-
// ../zql/src/query/dnf.ts
|
|
3117
|
-
function dnf(condition) {
|
|
3118
|
-
return unwrap(dnfInner(condition));
|
|
3119
|
-
}
|
|
3120
|
-
function dnfInner(condition) {
|
|
3121
|
-
switch (condition.type) {
|
|
3122
|
-
case "simple":
|
|
3123
|
-
case "correlatedSubquery":
|
|
3124
|
-
return { type: "or", conditions: [condition] };
|
|
3125
|
-
case "and":
|
|
3126
|
-
return distributeAnd(condition.conditions.map(dnfInner));
|
|
3127
|
-
case "or":
|
|
3128
|
-
return {
|
|
3129
|
-
type: "or",
|
|
3130
|
-
conditions: flatten(
|
|
3131
|
-
"or",
|
|
3132
|
-
condition.conditions.map(dnfInner).flatMap((c) => c.conditions)
|
|
3133
|
-
)
|
|
3134
|
-
};
|
|
3135
|
-
default:
|
|
3136
|
-
unreachable(condition);
|
|
3137
|
-
}
|
|
3138
|
-
}
|
|
3139
|
-
function distributeAnd(conditions) {
|
|
3140
|
-
if (conditions.length === 0) {
|
|
3141
|
-
return { type: "or", conditions: [TRUE] };
|
|
3142
|
-
}
|
|
3143
|
-
return conditions.reduce((acc, orCondition) => {
|
|
3144
|
-
const newConditions = [];
|
|
3145
|
-
for (const accCondition of acc.conditions) {
|
|
3146
|
-
for (const orSubCondition of orCondition.conditions) {
|
|
3147
|
-
newConditions.push({
|
|
3148
|
-
type: "and",
|
|
3149
|
-
conditions: [accCondition, orSubCondition]
|
|
3150
|
-
});
|
|
3151
|
-
}
|
|
3152
|
-
}
|
|
3153
|
-
return {
|
|
3154
|
-
type: "or",
|
|
3155
|
-
conditions: flatten("or", newConditions)
|
|
3156
|
-
};
|
|
3157
|
-
});
|
|
3158
|
-
}
|
|
3159
|
-
function unwrap(c) {
|
|
3160
|
-
if (c.type === "simple" || c.type === "correlatedSubquery") {
|
|
3161
|
-
return c;
|
|
3162
|
-
}
|
|
3163
|
-
if (c.conditions.length === 1) {
|
|
3164
|
-
return unwrap(c.conditions[0]);
|
|
3165
|
-
}
|
|
3166
|
-
return { type: c.type, conditions: flatten(c.type, c.conditions.map(unwrap)) };
|
|
3167
|
-
}
|
|
3168
|
-
|
|
3169
3098
|
// ../zql/src/query/query-impl.ts
|
|
3170
3099
|
var astSymbol = Symbol();
|
|
3171
3100
|
function newQuery(delegate, schema, table) {
|
|
@@ -3371,7 +3300,7 @@ var AbstractQuery = class {
|
|
|
3371
3300
|
if (existingWhere) {
|
|
3372
3301
|
cond = and(existingWhere, cond);
|
|
3373
3302
|
}
|
|
3374
|
-
const where =
|
|
3303
|
+
const where = simplifyCondition(cond);
|
|
3375
3304
|
if (this.#system === "client") {
|
|
3376
3305
|
assertNoNotExists(where);
|
|
3377
3306
|
}
|
|
@@ -3717,10 +3646,10 @@ export {
|
|
|
3717
3646
|
mapCondition,
|
|
3718
3647
|
hashOfAST,
|
|
3719
3648
|
filterPush,
|
|
3649
|
+
ExpressionBuilder,
|
|
3720
3650
|
createPredicate,
|
|
3721
3651
|
transformFilters,
|
|
3722
3652
|
assertOrderingIncludesPK,
|
|
3723
|
-
ExpressionBuilder,
|
|
3724
3653
|
DEFAULT_TTL,
|
|
3725
3654
|
parseTTL,
|
|
3726
3655
|
compareTTL,
|
|
@@ -3732,4 +3661,4 @@ export {
|
|
|
3732
3661
|
newQuerySymbol,
|
|
3733
3662
|
AbstractQuery
|
|
3734
3663
|
};
|
|
3735
|
-
//# sourceMappingURL=chunk-
|
|
3664
|
+
//# sourceMappingURL=chunk-MIYN75UK.js.map
|