okmodel 0.6.0 → 0.8.0
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/README.md +100 -1131
- package/dist/adapters/capabilities.d.ts +35 -0
- package/dist/adapters/failure.d.ts +13 -2
- package/dist/adapters/lazy-errors.d.ts +22 -0
- package/dist/adapters/pg/bun-sql.d.ts +53 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +54 -3
- package/dist/adapters/pg/bunsql.d.ts +15 -2
- package/dist/adapters/pg/cursor.d.ts +17 -0
- package/dist/adapters/pg/neon-extra.d.ts +18 -0
- package/dist/adapters/pg/neon.d.ts +104 -0
- package/dist/adapters/pg/no-inflight-timeout.d.ts +11 -8
- package/dist/adapters/pg/nodepostgres-extra.d.ts +22 -1
- package/dist/adapters/pg/nodepostgres.d.ts +12 -0
- package/dist/adapters/pg/pglite-wire.d.ts +24 -0
- package/dist/adapters/pg/pglite.d.ts +10 -0
- package/dist/adapters/pg/postgres-extra.d.ts +27 -11
- package/dist/adapters/pg/reserved.d.ts +42 -0
- package/dist/adapters/pg/session.d.ts +0 -18
- package/dist/contracts/connection.d.ts +7 -6
- package/dist/contracts/error.d.ts +1 -1
- package/dist/dialects/pg/floor.d.ts +68 -0
- package/dist/dialects/pg/fn/index.d.ts +39 -1
- package/dist/dialects/pg/fn/index.js +118 -26
- package/dist/dialects/pg/index.d.ts +8 -1
- package/dist/dialects/pg/index.js +435 -170
- package/dist/dialects/pg/introspect.d.ts +11 -0
- package/dist/dialects/pg/keys.d.ts +11 -8
- package/dist/dialects/pg/model.d.ts +40 -0
- package/dist/dialects/pg/morph.d.ts +43 -0
- package/dist/dialects/pg/operator-fit.d.ts +2 -2
- package/dist/dialects/pg/operators.d.ts +14 -7
- package/dist/dialects/pg/ops/bucket.d.ts +65 -0
- package/dist/dialects/pg/ops/fragment.d.ts +119 -0
- package/dist/dialects/pg/ops/inc.d.ts +2 -2
- package/dist/dialects/pg/ops/lane.d.ts +49 -0
- package/dist/dialects/pg/ops/matches.d.ts +9 -12
- package/dist/dialects/pg/ops/relevance.d.ts +13 -0
- package/dist/dialects/pg/ops/search-query.d.ts +22 -0
- package/dist/dialects/pg/ops/window.d.ts +103 -0
- package/dist/dialects/pg/preset.d.ts +1 -1
- package/dist/dialects/pg/relations.d.ts +100 -3
- package/dist/dialects/pg/schema.d.ts +31 -3
- package/dist/dialects/pg/view/client.d.ts +14 -6
- package/dist/dialects/pg/view/index.d.ts +73 -1
- package/dist/dialects/pg/view/index.js +156 -5
- package/dist/dialects/pg/view/scratch.d.ts +8 -5
- package/dist/runtime/aggregate.d.ts +8 -2
- package/dist/runtime/bucket-group.d.ts +70 -0
- package/dist/runtime/conflict.d.ts +22 -4
- package/dist/runtime/include.d.ts +0 -8
- package/dist/runtime/inflight.d.ts +1 -1
- package/dist/runtime/otel.d.ts +105 -0
- package/dist/runtime/otel.js +97 -0
- package/dist/runtime/page.d.ts +4 -1
- package/dist/runtime/pg/bun.js +12 -6
- package/dist/runtime/pg/neon.d.ts +38 -0
- package/dist/runtime/pg/neon.js +64 -0
- package/dist/runtime/pg/pg.js +5 -5
- package/dist/runtime/pg/pglite.d.ts +1 -0
- package/dist/runtime/pg/pglite.js +9 -9
- package/dist/runtime/pg/postgresjs.js +5 -5
- package/dist/runtime/plan.d.ts +95 -5
- package/dist/runtime/read-stream.d.ts +13 -16
- package/dist/runtime/result-name.d.ts +17 -0
- package/dist/runtime/server-check.d.ts +3 -3
- package/dist/runtime/sort-bind.d.ts +21 -0
- package/dist/runtime/sort.d.ts +56 -0
- package/dist/runtime/sql-fragment.d.ts +43 -0
- package/dist/runtime/sync.d.ts +70 -0
- package/dist/runtime/tenancy/index.js +15 -13
- package/dist/runtime/text-search.d.ts +20 -0
- package/dist/runtime/topology.d.ts +1 -1
- package/dist/runtime/traits/index.d.ts +80 -0
- package/dist/runtime/traits/index.js +184 -21
- package/dist/runtime/tree.d.ts +38 -0
- package/dist/runtime/types.d.ts +232 -22
- package/dist/runtime/validate/index.js +4 -4
- package/dist/runtime/version.d.ts +39 -0
- package/dist/runtime/window.d.ts +21 -0
- package/dist/runtime/write.d.ts +54 -2
- package/dist/shared/{929h19xp.js → 0wrea3jq.js} +141 -13
- package/dist/shared/{qq3899ht.js → 12z7aznj.js} +243 -14
- package/dist/shared/{1z04fa85.js → 14x60fbf.js} +12 -57
- package/dist/shared/{ek2wt2dz.js → 16kvjebh.js} +4 -4
- package/dist/shared/{wynzeggs.js → 195pzzzz.js} +8 -8
- package/dist/shared/1d9q9cv2.js +312 -0
- package/dist/shared/2c13q96h.js +18 -0
- package/dist/shared/{b4v57v3x.js → 2d3xq4ps.js} +2 -2
- package/dist/shared/{1f0xa3cb.js → 3449rcae.js} +5 -5
- package/dist/shared/{wkme6tep.js → 35q0n9tz.js} +8 -16
- package/dist/shared/3bb7wsqt.js +99 -0
- package/dist/shared/3t6kw83m.js +249 -0
- package/dist/shared/{5j36z8dn.js → 4m6hskg8.js} +39 -70
- package/dist/shared/{n076ydsc.js → 4vbf83xx.js} +69 -28
- package/dist/shared/{vmfkhszw.js → 63f4ksbz.js} +33 -26
- package/dist/shared/{c58secgj.js → 63qtkrca.js} +38 -4
- package/dist/shared/6m78c8ss.js +6 -0
- package/dist/shared/{x3jc53kg.js → 760ppr76.js} +15 -7
- package/dist/shared/7ghwamrf.js +40 -0
- package/dist/shared/7kms6fvj.js +20 -0
- package/dist/shared/7n7ddwt4.js +6 -0
- package/dist/shared/9a4ae4p8.js +31 -0
- package/dist/shared/{hazqqecq.js → 9dr2qnx7.js} +63 -34
- package/dist/shared/{h15jx9bc.js → 9dvh1dr6.js} +1 -1
- package/dist/shared/a62rb2da.js +13 -0
- package/dist/shared/{cgbamx3e.js → ae4j5f42.js} +23 -4
- package/dist/shared/agsfb86s.js +233 -0
- package/dist/shared/{8x72s86k.js → b6d6p0zc.js} +13 -7
- package/dist/shared/{ag4c7516.js → b76b8d95.js} +2 -2
- package/dist/shared/{j60w0dvr.js → bah9nbg3.js} +58 -38
- package/dist/shared/bnby0esn.js +10 -0
- package/dist/shared/bsek72fg.js +225 -0
- package/dist/shared/{2cg3wnxc.js → bxas03mq.js} +608 -141
- package/dist/shared/{31vm914h.js → cm3w0ywp.js} +15 -16
- package/dist/shared/{gwn6v667.js → cnkky55j.js} +25 -14
- package/dist/shared/{dk8v79p3.js → d5nmj7vv.js} +1 -1
- package/dist/shared/{ttmg09vd.js → dpc2r7rb.js} +8 -8
- package/dist/shared/dzj09cye.js +10 -0
- package/dist/shared/{sbdme3vy.js → e8zyaqvj.js} +60 -10
- package/dist/shared/{2jd1sn0e.js → ecn8mfdq.js} +6 -6
- package/dist/shared/exn3sd90.js +359 -0
- package/dist/shared/{t3g0k88x.js → f4jy1j7x.js} +39 -22
- package/dist/shared/{y2t3jktd.js → fjpnhqan.js} +20 -13
- package/dist/shared/g5yc06ka.js +272 -0
- package/dist/shared/ga9j92qj.js +25 -0
- package/dist/shared/{3fqwmr09.js → hfqmpasr.js} +6 -6
- package/dist/shared/{wt5rzv1h.js → hm5f8jby.js} +7 -7
- package/dist/shared/{ys0xzyaj.js → hqpxf4a4.js} +224 -19
- package/dist/shared/jebgrkeq.js +179 -0
- package/dist/shared/{09p049xa.js → jp36k7dp.js} +44 -16
- package/dist/shared/jx2m62cs.js +96 -0
- package/dist/shared/{r11n8grd.js → k86n8vq3.js} +7 -4
- package/dist/shared/{2z7wv5tj.js → kgwp4jdd.js} +56 -35
- package/dist/shared/{knmes2kh.js → kj9d8maq.js} +1 -1
- package/dist/shared/{g90m9b0g.js → m4xff2a6.js} +6 -5
- package/dist/shared/{r6nwkxnt.js → m7n9h2a5.js} +4 -4
- package/dist/shared/mfedzr74.js +145 -0
- package/dist/shared/{f0f1n281.js → mkrn359n.js} +60 -11
- package/dist/shared/{p248q79y.js → mnvjvqyp.js} +10 -10
- package/dist/shared/{672t5vym.js → mss6ctgv.js} +2 -2
- package/dist/shared/{4az561fn.js → mtw6jz76.js} +8 -23
- package/dist/shared/n05z9nwz.js +313 -0
- package/dist/shared/{pjr6xrm5.js → n0jmpgj1.js} +20 -17
- package/dist/shared/{p6bjzq9q.js → n41w4fbz.js} +14 -6
- package/dist/shared/{b3awxn7h.js → n454kcnw.js} +1 -1
- package/dist/shared/n7kg8mmx.js +61 -0
- package/dist/shared/nbw1z4yd.js +18 -0
- package/dist/shared/needfe47.js +66 -0
- package/dist/shared/{1nw1f3vs.js → njga14v4.js} +9 -9
- package/dist/shared/{5yv4k6a6.js → nmnsgj7x.js} +145 -3
- package/dist/shared/{vjpnzwjz.js → p3xbdcvt.js} +14 -18
- package/dist/shared/p5nh3r8q.js +622 -0
- package/dist/shared/{nx9hh281.js → pan0370z.js} +13 -12
- package/dist/shared/q0cqt2sp.js +12 -0
- package/dist/shared/qd9hhd8f.js +37 -0
- package/dist/shared/{mb2ycs1p.js → qfw14tna.js} +15 -15
- package/dist/shared/{9s0ypp87.js → sjk86yrx.js} +1 -1
- package/dist/shared/th3be82n.js +208 -0
- package/dist/shared/{ed0b8k4s.js → typ3vy7t.js} +1 -1
- package/dist/shared/{5d8t84hg.js → v1wad97q.js} +14 -14
- package/dist/shared/{x72jb7ad.js → v8g1vgv8.js} +1 -1
- package/dist/shared/{9628a9xt.js → vk7rag46.js} +1 -1
- package/dist/shared/{ze4hxsmy.js → w9ejzaqf.js} +1 -1
- package/dist/shared/{q3j1tq7a.js → wcrheftc.js} +148 -23
- package/dist/shared/wvdjznah.js +213 -0
- package/dist/shared/wz2a78mp.js +8 -0
- package/dist/shared/xfhe73sb.js +436 -0
- package/dist/shared/{r1fdd0f6.js → z581d7ny.js} +5 -2
- package/dist/shared/{8etn7d8w.js → z7s6fpxv.js} +1 -1
- package/dist/shared/{32cnm7kn.js → zbqbmmrp.js} +76 -40
- package/dist/shared/{n7mcc1gk.js → zchaghkf.js} +4 -3
- package/dist/shared/{xq0mvhts.js → zgex00fd.js} +6 -6
- package/dist/shared/{nsva2a6b.js → znm0bpp5.js} +3 -0
- package/dist/shared/zq1he88x.js +155 -0
- package/dist/tooling/cli.js +26 -13
- package/dist/tooling/driver-run.js +4971 -0
- package/dist/tooling/driver-test.d.ts +36 -0
- package/dist/tooling/migrate/commands.d.ts +2 -2
- package/dist/tooling/migrate/engine.d.ts +3 -2
- package/dist/tooling/migrate/index.js +9 -9
- package/dist/tooling/migrate/project.d.ts +3 -0
- package/dist/tooling/shared/03k6res6.js +210 -0
- package/dist/tooling/shared/08kemxjd.js +10 -0
- package/dist/tooling/shared/2revefqt.js +209 -0
- package/dist/tooling/shared/2wtvc7rw.js +1425 -0
- package/dist/tooling/shared/345tbc2k.js +16 -0
- package/dist/tooling/shared/3m1hkg7z.js +344 -0
- package/dist/tooling/shared/3rrw5w8f.js +81 -0
- package/dist/tooling/shared/3tq8pnb8.js +131 -0
- package/dist/tooling/shared/417zdsk7.js +194 -0
- package/dist/tooling/shared/4d2w25vw.js +40 -0
- package/dist/tooling/shared/54tqkxja.js +51 -0
- package/dist/tooling/shared/5bvw2nev.js +12 -0
- package/dist/tooling/shared/6nyfyw70.js +231 -0
- package/dist/tooling/shared/72fyg4zv.js +160 -0
- package/dist/tooling/shared/733a1tq3.js +38 -0
- package/dist/tooling/shared/7ae7rjmn.js +20 -0
- package/dist/tooling/shared/7kms6fvj.js +20 -0
- package/dist/tooling/shared/8sqrsw3s.js +49 -0
- package/dist/tooling/shared/96ps4g1z.js +32 -0
- package/dist/tooling/shared/9kazs5p6.js +195 -0
- package/dist/tooling/shared/9xzm7hjg.js +38 -0
- package/dist/tooling/shared/a6pp9d12.js +49 -0
- package/dist/tooling/shared/a7q7t4n3.js +22 -0
- package/dist/tooling/shared/aftb2mwr.js +18 -0
- package/dist/tooling/shared/bz2dqhab.js +311 -0
- package/dist/tooling/shared/cmptmb4f.js +12 -0
- package/dist/tooling/shared/ddjtfgnx.js +177 -0
- package/dist/tooling/shared/djydjpqt.js +261 -0
- package/dist/tooling/shared/dw08f3m8.js +9 -0
- package/dist/tooling/shared/dy672fz6.js +16 -0
- package/dist/tooling/shared/dzx85q70.js +66 -0
- package/dist/tooling/shared/ec71zqgt.js +270 -0
- package/dist/{shared/d5azex6s.js → tooling/shared/ep8zh3bk.js} +1 -1
- package/dist/tooling/shared/f9mphxej.js +3789 -0
- package/dist/tooling/shared/fb9k2qwd.js +89 -0
- package/dist/tooling/shared/g9ad4n80.js +211 -0
- package/dist/tooling/shared/gfvtj6d0.js +94 -0
- package/dist/tooling/shared/gmcf9cxf.js +294 -0
- package/dist/tooling/shared/htnaj77v.js +17 -0
- package/dist/tooling/shared/j9t5s12a.js +7 -0
- package/dist/tooling/shared/jne7b93p.js +42 -0
- package/dist/tooling/shared/ma2340rx.js +118 -0
- package/dist/tooling/shared/mtrqn2hn.js +505 -0
- package/dist/tooling/shared/n4jqhpqz.js +27 -0
- package/dist/tooling/shared/nf7jmhfa.js +20 -0
- package/dist/tooling/shared/p7f08ktn.js +332 -0
- package/dist/tooling/shared/ppnnnvj8.js +13 -0
- package/dist/tooling/shared/pqy21k24.js +312 -0
- package/dist/tooling/shared/pw8fgahx.js +69 -0
- package/dist/tooling/shared/pwsytxm5.js +17 -0
- package/dist/tooling/shared/rf83gr2d.js +94 -0
- package/dist/tooling/shared/rq5kk8j6.js +401 -0
- package/dist/tooling/shared/rs1jb051.js +12 -0
- package/dist/tooling/shared/smn6kz1p.js +157 -0
- package/dist/tooling/shared/spk1jg3r.js +1696 -0
- package/dist/tooling/shared/tn8gay14.js +143 -0
- package/dist/tooling/shared/vraj6d74.js +42 -0
- package/dist/tooling/shared/vs0t6qt8.js +64 -0
- package/dist/tooling/shared/vx86qjv8.js +150 -0
- package/dist/tooling/shared/w7qe8sj1.js +140 -0
- package/dist/tooling/shared/wt7j7nf6.js +15 -0
- package/dist/tooling/shared/wwnekq5n.js +6 -0
- package/dist/tooling/shared/xhrnjch9.js +185 -0
- package/dist/tooling/shared/xjs6zqtc.js +190 -0
- package/dist/tooling/shared/y031jct9.js +16 -0
- package/dist/tooling/shared/y5656f0e.js +233 -0
- package/dist/tooling/shared/yfr8hzhm.js +604 -0
- package/dist/tooling/shared/yk9mp7vb.js +250 -0
- package/dist/tooling/shared/yw30vnq2.js +139 -0
- package/dist/tooling/shared/z8d7ptht.js +618 -0
- package/dist/tooling/shared/zhwnfyb2.js +9 -0
- package/dist/tooling/shared/zvnhh1n0.js +198 -0
- package/dist/tooling/testing/index.js +3 -3
- package/package.json +17 -3
- package/dist/shared/3qnhc7w5.js +0 -38
- package/dist/shared/7m88x3e9.js +0 -45
- package/dist/shared/8dqhth8c.js +0 -12
- package/dist/shared/j3rkk835.js +0 -99
- package/dist/shared/k68eedmy.js +0 -85
- package/dist/shared/venqrjna.js +0 -216
- package/dist/shared/wxr8cwns.js +0 -6
- package/dist/shared/y34a8714.js +0 -150
- package/dist/shared/zm0mafk4.js +0 -92
- package/dist/shared/zy8r7qvz.js +0 -116
- package/dist/shared/{ywr8hmey.js → 606g0nbf.js} +3 -3
- package/dist/shared/{rpycarcr.js → gcefca6p.js} +4 -4
package/dist/shared/venqrjna.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
readHandle,
|
|
3
|
-
readCall,
|
|
4
|
-
attachHttp
|
|
5
|
-
} from "./j60w0dvr.js";
|
|
6
|
-
import {
|
|
7
|
-
emitWhere,
|
|
8
|
-
emitOrder,
|
|
9
|
-
refuseHidden,
|
|
10
|
-
rejectKeys,
|
|
11
|
-
readLimit,
|
|
12
|
-
projectExpr,
|
|
13
|
-
cell,
|
|
14
|
-
indexes,
|
|
15
|
-
quote,
|
|
16
|
-
list,
|
|
17
|
-
isRecord,
|
|
18
|
-
fail
|
|
19
|
-
} from "./2z7wv5tj.js";
|
|
20
|
-
import {
|
|
21
|
-
OkmError2,
|
|
22
|
-
throwNamed2
|
|
23
|
-
} from "./52szzakm.js";
|
|
24
|
-
|
|
25
|
-
// src/runtime/aggregate.ts
|
|
26
|
-
var OPTIONS = [
|
|
27
|
-
"where",
|
|
28
|
-
"groupBy",
|
|
29
|
-
"count",
|
|
30
|
-
"sum",
|
|
31
|
-
"avg",
|
|
32
|
-
"min",
|
|
33
|
-
"max",
|
|
34
|
-
"orderBy",
|
|
35
|
-
"limit",
|
|
36
|
-
"route",
|
|
37
|
-
"signal",
|
|
38
|
-
"timeout"
|
|
39
|
-
];
|
|
40
|
-
var NUMERIC = /^(smallint|integer|bigint|real|double precision|numeric|decimal)\b/;
|
|
41
|
-
var AS_NUMBER = (wire) => Number(wire);
|
|
42
|
-
var AS_TEXT = (wire) => wire;
|
|
43
|
-
var UNORDERED = /^(json|jsonb|bytea|point|line|tsvector)\b|\[\]$/;
|
|
44
|
-
var FUNCTIONS = [
|
|
45
|
-
{ option: "sum", tag: "s", numeric: true },
|
|
46
|
-
{ option: "avg", tag: "a", numeric: true },
|
|
47
|
-
{ option: "min", tag: "n", numeric: false },
|
|
48
|
-
{ option: "max", tag: "x", numeric: false }
|
|
49
|
-
];
|
|
50
|
-
function build(session, table, options, mods, view) {
|
|
51
|
-
try {
|
|
52
|
-
return plan(session, table, options, mods, view);
|
|
53
|
-
} catch (error) {
|
|
54
|
-
throw error instanceof OkmError2 ? attachHttp(session.http, error) : error;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function plan(session, table, options, mods, view) {
|
|
58
|
-
const record = isRecord(options) ? options : {};
|
|
59
|
-
rejectKeys(record, OPTIONS, "aggregate");
|
|
60
|
-
const indexed = indexes(session.schema).get(table);
|
|
61
|
-
if (indexed === undefined)
|
|
62
|
-
fail("OKM1120", `Table ${table} is not in the schema.`);
|
|
63
|
-
const spec = parse(indexed, record);
|
|
64
|
-
if (spec.groups.length > 0 && record.limit === undefined && mods.all === undefined) {
|
|
65
|
-
fail("OKM1101", "aggregate() with groupBy needs a limit, or .all(reason) for every group.");
|
|
66
|
-
}
|
|
67
|
-
const orderBy = record.orderBy;
|
|
68
|
-
if (orderBy !== undefined) {
|
|
69
|
-
if (!isRecord(orderBy))
|
|
70
|
-
fail("OKM1120", "orderBy must be an object of fields.");
|
|
71
|
-
for (const field of Object.keys(orderBy)) {
|
|
72
|
-
const column = indexed.columns.get(field);
|
|
73
|
-
if (column !== undefined)
|
|
74
|
-
refuseHidden(column);
|
|
75
|
-
if (!spec.groups.some((group) => group.field === field)) {
|
|
76
|
-
throwNamed2("OKM1120", field, spec.groups.map((group) => group.field), `aggregate() orders by a groupBy field. Accepted names: ${list(spec.groups.map((group) => group.field))}.`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (record.limit !== undefined)
|
|
81
|
-
readLimit(record.limit);
|
|
82
|
-
const base = readCall("find", table, {
|
|
83
|
-
where: record.where,
|
|
84
|
-
orderBy,
|
|
85
|
-
limit: record.limit,
|
|
86
|
-
signal: record.signal,
|
|
87
|
-
timeout: record.timeout,
|
|
88
|
-
route: record.route
|
|
89
|
-
}, mods.all, session.scope, session.schema.model[table], session.schema, view);
|
|
90
|
-
const call = { ...base, op: "aggregate", build: statement(spec) };
|
|
91
|
-
return readHandle(session, table, call, mods, (compiled, rows) => decode(compiled, rows));
|
|
92
|
-
}
|
|
93
|
-
function parse(table, record) {
|
|
94
|
-
const groups = columns(table, record.groupBy, "groupBy");
|
|
95
|
-
const count = record.count === true;
|
|
96
|
-
if (record.count !== undefined && typeof record.count !== "boolean") {
|
|
97
|
-
fail("OKM1120", "count is true when you want a row count.");
|
|
98
|
-
}
|
|
99
|
-
const calls = [];
|
|
100
|
-
for (const { option, tag, numeric } of FUNCTIONS) {
|
|
101
|
-
for (const column of columns(table, record[option], option)) {
|
|
102
|
-
const fits = numeric ? NUMERIC.test(column.dataType) : !UNORDERED.test(column.dataType);
|
|
103
|
-
if (!fits) {
|
|
104
|
-
fail("OKM1124", `${option} does not apply to ${column.dataType} column ${column.field}. ${numeric ? "sum and avg take integer, real, and numeric columns." : "min and max need an ordered type."}`);
|
|
105
|
-
}
|
|
106
|
-
calls.push({ option, tag, column, decode: numeric ? sumDecode(column) : column.decode });
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (!count && calls.length === 0 && groups.length === 0) {
|
|
110
|
-
fail("OKM1120", "aggregate() needs count, sum, avg, min, max, or groupBy.");
|
|
111
|
-
}
|
|
112
|
-
return { groups, count, calls };
|
|
113
|
-
}
|
|
114
|
-
function sumDecode(column) {
|
|
115
|
-
const kind = typeof (column.decode?.("0") ?? "");
|
|
116
|
-
if (kind === "string")
|
|
117
|
-
return AS_TEXT;
|
|
118
|
-
if (kind === "number")
|
|
119
|
-
return AS_NUMBER;
|
|
120
|
-
return fail("OKM1124", `sum and avg need a column whose value is a number or a string. ${column.field} reads as ${kind}.`);
|
|
121
|
-
}
|
|
122
|
-
function columns(table, value, option) {
|
|
123
|
-
if (value === undefined)
|
|
124
|
-
return [];
|
|
125
|
-
if (!Array.isArray(value))
|
|
126
|
-
fail("OKM1120", `${option} must be a list of field names.`);
|
|
127
|
-
const out = [];
|
|
128
|
-
for (const name of value) {
|
|
129
|
-
const column = typeof name === "string" ? table.columns.get(name) : undefined;
|
|
130
|
-
if (typeof name !== "string" || column === undefined) {
|
|
131
|
-
throwNamed2("OKM1120", String(name), table.names, `Field ${String(name)} is not on ${table.model.name}. Accepted names: ${list(table.names)}.`);
|
|
132
|
-
}
|
|
133
|
-
if (column.hidden) {
|
|
134
|
-
fail("OKM1120", `Field ${column.field} is hidden, so ${option} cannot read it.`);
|
|
135
|
-
}
|
|
136
|
-
out.push(column);
|
|
137
|
-
}
|
|
138
|
-
return out;
|
|
139
|
-
}
|
|
140
|
-
function statement(spec) {
|
|
141
|
-
return (schema, table, sink, outputs, call) => {
|
|
142
|
-
sink.mark(`aggregate|${table.model.name}|g:${spec.groups.map((column) => column.field).join(",")}|c:${String(spec.count)}|${spec.calls.map((item) => `${item.tag}:${item.column.field}`).join(",")}|`);
|
|
143
|
-
sink.text("select ");
|
|
144
|
-
const wrote = { at: 0 };
|
|
145
|
-
for (const column of spec.groups) {
|
|
146
|
-
put(sink, outputs, wrote, projectExpr(`t.${quote(column.sql)}`, column.dataType), {
|
|
147
|
-
key: `g:${column.field}`,
|
|
148
|
-
decode: column.decode
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
if (spec.count)
|
|
152
|
-
put(sink, outputs, wrote, "count(*)::text", { key: "c:", decode: undefined });
|
|
153
|
-
for (const item of spec.calls) {
|
|
154
|
-
const ref = `t.${quote(item.column.sql)}`;
|
|
155
|
-
const expr = item.option === "sum" || item.option === "avg" ? `${item.option}(${ref})::text` : projectExpr(`${item.option}(${ref})`, item.column.dataType);
|
|
156
|
-
put(sink, outputs, wrote, expr, {
|
|
157
|
-
key: `${item.tag}:${item.column.field}`,
|
|
158
|
-
decode: item.decode
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
sink.text(" from ");
|
|
162
|
-
sink.text(quote(table.model.sql));
|
|
163
|
-
sink.text(" t");
|
|
164
|
-
emitWhere(schema, table, call.where, sink, "t", 0);
|
|
165
|
-
if (spec.groups.length > 0) {
|
|
166
|
-
sink.text(" group by ");
|
|
167
|
-
sink.text(spec.groups.map((column) => `t.${quote(column.sql)}`).join(", "));
|
|
168
|
-
if (isRecord(call.orderBy) && Object.keys(call.orderBy).length > 0) {
|
|
169
|
-
emitOrder(table, call.orderBy, sink, "t");
|
|
170
|
-
} else {
|
|
171
|
-
sink.text(" order by ");
|
|
172
|
-
sink.text(spec.groups.map((column) => `t.${quote(column.sql)} asc nulls last`).join(", "));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (call.limit !== undefined) {
|
|
176
|
-
const limit = String(call.limit);
|
|
177
|
-
sink.text(" limit ");
|
|
178
|
-
sink.param(limit);
|
|
179
|
-
sink.mark(`l:${limit}`);
|
|
180
|
-
}
|
|
181
|
-
if (typeof call.all === "string")
|
|
182
|
-
sink.mark(`all:${call.all}`);
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
function put(sink, outputs, wrote, expr, out) {
|
|
186
|
-
if (wrote.at > 0)
|
|
187
|
-
sink.text(", ");
|
|
188
|
-
sink.text(expr);
|
|
189
|
-
outputs?.fields.push({ key: out.key, at: wrote.at, decode: out.decode });
|
|
190
|
-
wrote.at += 1;
|
|
191
|
-
}
|
|
192
|
-
function decode(compiled, rows) {
|
|
193
|
-
const items = [];
|
|
194
|
-
for (const row of rows) {
|
|
195
|
-
const item = {};
|
|
196
|
-
for (const field of compiled.outputs.fields) {
|
|
197
|
-
const value = row[field.at];
|
|
198
|
-
const tag = field.key.slice(0, 2);
|
|
199
|
-
const name = field.key.slice(2);
|
|
200
|
-
if (tag === "g:") {
|
|
201
|
-
item[name] = cell(value, field.decode);
|
|
202
|
-
} else if (tag === "c:") {
|
|
203
|
-
item.count = Number(value ?? 0);
|
|
204
|
-
} else {
|
|
205
|
-
const group = tag === "s:" ? "sum" : tag === "a:" ? "avg" : tag === "n:" ? "min" : "max";
|
|
206
|
-
const into = item[group] ??= {};
|
|
207
|
-
into[name] = cell(value, field.decode);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
items.push(item);
|
|
211
|
-
}
|
|
212
|
-
return items;
|
|
213
|
-
}
|
|
214
|
-
export {
|
|
215
|
-
build
|
|
216
|
-
};
|
package/dist/shared/wxr8cwns.js
DELETED
package/dist/shared/y34a8714.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
staticNamespace2,
|
|
3
|
-
assertNamespace2,
|
|
4
|
-
normaliseEdges,
|
|
5
|
-
assertProvenance
|
|
6
|
-
} from "./358zsv4r.js";
|
|
7
|
-
import {
|
|
8
|
-
assertIdentifier2
|
|
9
|
-
} from "./nfzc5z0w.js";
|
|
10
|
-
import {
|
|
11
|
-
catalogError2
|
|
12
|
-
} from "./52szzakm.js";
|
|
13
|
-
|
|
14
|
-
// src/contracts/catalog/routine.ts
|
|
15
|
-
var VOLATILITY = new Set(["volatile", "stable", "immutable"]);
|
|
16
|
-
var SECURITY = new Set(["invoker", "definer"]);
|
|
17
|
-
var TIMING = new Set(["before", "after", "instead"]);
|
|
18
|
-
var LEVEL = new Set(["row", "statement"]);
|
|
19
|
-
var EVENT_ORDER = ["insert", "update", "delete", "truncate"];
|
|
20
|
-
var TYPE_TEXT = /^[A-Za-z][A-Za-z0-9_ ]*(\(\d+(,\s*\d+)?\))?(\[\])*$/;
|
|
21
|
-
function functionObject(input) {
|
|
22
|
-
assertIdentifier2(input.name, "function");
|
|
23
|
-
const namespace = input.namespace ?? staticNamespace2("public");
|
|
24
|
-
assertNamespace2(namespace);
|
|
25
|
-
assertProvenance(input.provenance);
|
|
26
|
-
if (input.language !== "sql" && input.language !== "plpgsql") {
|
|
27
|
-
catalogError2("OKM1020", `Function ${input.name} language must be sql or plpgsql.`);
|
|
28
|
-
}
|
|
29
|
-
const volatility = input.volatility ?? "volatile";
|
|
30
|
-
if (!VOLATILITY.has(volatility)) {
|
|
31
|
-
catalogError2("OKM1020", `Function ${input.name} volatility ${volatility} is not supported.`);
|
|
32
|
-
}
|
|
33
|
-
const security = input.security ?? "invoker";
|
|
34
|
-
if (!SECURITY.has(security)) {
|
|
35
|
-
catalogError2("OKM1020", `Function ${input.name} security ${security} is not supported.`);
|
|
36
|
-
}
|
|
37
|
-
assertTypeName(input.returns, `function ${input.name} return type`);
|
|
38
|
-
const args = (input.arguments ?? []).map((argument) => readArgument(input.name, argument));
|
|
39
|
-
if (input.body.length === 0) {
|
|
40
|
-
catalogError2("OKM1020", `Function ${input.name} needs a body.`);
|
|
41
|
-
}
|
|
42
|
-
const atomic = input.atomic === true;
|
|
43
|
-
if (atomic && input.language !== "sql") {
|
|
44
|
-
catalogError2("OKM1020", `Function ${input.name} BEGIN ATOMIC needs language sql.`);
|
|
45
|
-
}
|
|
46
|
-
if (input.searchPath !== undefined && input.searchPath.trim().length === 0) {
|
|
47
|
-
catalogError2("OKM1020", `Function ${input.name} search_path is empty.`);
|
|
48
|
-
}
|
|
49
|
-
const definition = {
|
|
50
|
-
arguments: args,
|
|
51
|
-
returns: input.returns,
|
|
52
|
-
language: input.language,
|
|
53
|
-
volatility,
|
|
54
|
-
security,
|
|
55
|
-
body: input.body,
|
|
56
|
-
...input.searchPath !== undefined ? { searchPath: input.searchPath } : {},
|
|
57
|
-
...atomic ? { atomic: true } : {}
|
|
58
|
-
};
|
|
59
|
-
return {
|
|
60
|
-
kind: "function",
|
|
61
|
-
identity: {
|
|
62
|
-
kind: "function",
|
|
63
|
-
namespace,
|
|
64
|
-
name: input.name,
|
|
65
|
-
argTypes: args.map((arg) => arg.type)
|
|
66
|
-
},
|
|
67
|
-
owner: input.owner ?? "managed",
|
|
68
|
-
definition,
|
|
69
|
-
dependencies: normaliseEdges(input.dependencies ?? []),
|
|
70
|
-
provenance: input.provenance
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function triggerObject(input) {
|
|
74
|
-
assertIdentifier2(input.name, "trigger");
|
|
75
|
-
assertNamespace2(input.parent.namespace);
|
|
76
|
-
assertIdentifier2(input.parent.name, "trigger table");
|
|
77
|
-
assertProvenance(input.provenance);
|
|
78
|
-
if (!TIMING.has(input.timing)) {
|
|
79
|
-
catalogError2("OKM1020", `Trigger ${input.name} timing ${input.timing} is not supported.`);
|
|
80
|
-
}
|
|
81
|
-
if (!LEVEL.has(input.level)) {
|
|
82
|
-
catalogError2("OKM1020", `Trigger ${input.name} level ${input.level} is not supported.`);
|
|
83
|
-
}
|
|
84
|
-
const events = EVENT_ORDER.filter((event) => input.events.includes(event));
|
|
85
|
-
if (events.length === 0) {
|
|
86
|
-
catalogError2("OKM1020", `Trigger ${input.name} needs an event.`);
|
|
87
|
-
}
|
|
88
|
-
const updateOf = input.updateOf === undefined ? undefined : [...input.updateOf];
|
|
89
|
-
if (updateOf !== undefined) {
|
|
90
|
-
if (!events.includes("update")) {
|
|
91
|
-
catalogError2("OKM1020", `Trigger ${input.name} lists UPDATE OF columns without an update event.`);
|
|
92
|
-
}
|
|
93
|
-
if (input.level !== "row") {
|
|
94
|
-
catalogError2("OKM1020", `Trigger ${input.name} UPDATE OF columns need level row.`);
|
|
95
|
-
}
|
|
96
|
-
for (const column of updateOf)
|
|
97
|
-
assertIdentifier2(column, "trigger column");
|
|
98
|
-
}
|
|
99
|
-
assertIdentifier2(input.calls.name, "trigger function");
|
|
100
|
-
assertNamespace2(input.calls.namespace);
|
|
101
|
-
for (const typeName of input.calls.argTypes)
|
|
102
|
-
assertTypeName(typeName, `trigger ${input.name}`);
|
|
103
|
-
const edges = [
|
|
104
|
-
{ kind: "table", namespace: input.parent.namespace, name: input.parent.name },
|
|
105
|
-
{
|
|
106
|
-
kind: "function",
|
|
107
|
-
namespace: input.calls.namespace,
|
|
108
|
-
name: input.calls.name,
|
|
109
|
-
argTypes: input.calls.argTypes
|
|
110
|
-
},
|
|
111
|
-
...(updateOf ?? []).map((column) => ({
|
|
112
|
-
kind: "column",
|
|
113
|
-
parent: input.parent,
|
|
114
|
-
name: column
|
|
115
|
-
})),
|
|
116
|
-
...input.dependencies ?? []
|
|
117
|
-
];
|
|
118
|
-
const definition = {
|
|
119
|
-
timing: input.timing,
|
|
120
|
-
events,
|
|
121
|
-
level: input.level,
|
|
122
|
-
calls: {
|
|
123
|
-
namespace: input.calls.namespace,
|
|
124
|
-
name: input.calls.name,
|
|
125
|
-
argTypes: [...input.calls.argTypes]
|
|
126
|
-
},
|
|
127
|
-
...updateOf !== undefined && updateOf.length > 0 ? { updateOf } : {},
|
|
128
|
-
...input.when !== undefined && input.when.length > 0 ? { when: input.when } : {}
|
|
129
|
-
};
|
|
130
|
-
return {
|
|
131
|
-
kind: "trigger",
|
|
132
|
-
identity: { kind: "trigger", parent: input.parent, name: input.name },
|
|
133
|
-
owner: input.owner ?? "managed",
|
|
134
|
-
definition,
|
|
135
|
-
dependencies: normaliseEdges(edges),
|
|
136
|
-
provenance: input.provenance
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function readArgument(fn, argument) {
|
|
140
|
-
assertIdentifier2(argument.name, `function ${fn} argument`);
|
|
141
|
-
assertTypeName(argument.type, `function ${fn} argument ${argument.name}`);
|
|
142
|
-
return { name: argument.name, type: argument.type };
|
|
143
|
-
}
|
|
144
|
-
function assertTypeName(typeName, role) {
|
|
145
|
-
if (!TYPE_TEXT.test(typeName)) {
|
|
146
|
-
catalogError2("OKM1020", `${role} ${typeName} is not a type name.`);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export { functionObject, triggerObject };
|
package/dist/shared/zm0mafk4.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DriverError2
|
|
3
|
-
} from "./31vm914h.js";
|
|
4
|
-
import {
|
|
5
|
-
send,
|
|
6
|
-
connectClient
|
|
7
|
-
} from "./1z04fa85.js";
|
|
8
|
-
import {
|
|
9
|
-
isConnectionLost
|
|
10
|
-
} from "./gwn6v667.js";
|
|
11
|
-
import {
|
|
12
|
-
WireSession
|
|
13
|
-
} from "./4az561fn.js";
|
|
14
|
-
import {
|
|
15
|
-
rejectClosed,
|
|
16
|
-
runCall
|
|
17
|
-
} from "./cgbamx3e.js";
|
|
18
|
-
|
|
19
|
-
// src/adapters/pg/nodepostgres-extra.ts
|
|
20
|
-
var RESET_ALL = "RESET ALL";
|
|
21
|
-
var UNLOCK = "SELECT pg_advisory_unlock_all()";
|
|
22
|
-
async function checkout(held) {
|
|
23
|
-
const { pool, counters, named, isClosed } = held;
|
|
24
|
-
if (isClosed())
|
|
25
|
-
return rejectClosed();
|
|
26
|
-
const client = await connectClient(pool, held.acquireMs, counters);
|
|
27
|
-
counters.reserved += 1;
|
|
28
|
-
let lost = false;
|
|
29
|
-
const onError = () => {
|
|
30
|
-
lost = true;
|
|
31
|
-
};
|
|
32
|
-
const events = client;
|
|
33
|
-
events.on("error", onError);
|
|
34
|
-
const local = new Set;
|
|
35
|
-
const session = new WireSession((text, params) => send(client, text, params, named, client), held.notices, isClosed, true, () => {
|
|
36
|
-
counters.reservedBusy += 1;
|
|
37
|
-
}, () => {
|
|
38
|
-
counters.reservedBusy = Math.max(0, counters.reservedBusy - 1);
|
|
39
|
-
}, local);
|
|
40
|
-
const guard = (run) => lost ? rejectClosed("CONNECTION_CLOSED") : run().catch((error) => {
|
|
41
|
-
if (isConnectionLost(error))
|
|
42
|
-
lost = true;
|
|
43
|
-
if (error instanceof Error && error.message.includes("Connection terminated")) {
|
|
44
|
-
throw new DriverError2("CONNECTION_CLOSED", { cause: error });
|
|
45
|
-
}
|
|
46
|
-
throw error;
|
|
47
|
-
});
|
|
48
|
-
let released = false;
|
|
49
|
-
return {
|
|
50
|
-
execute: (text, params, options) => guard(() => runCall(isClosed(), options, (watch) => session.query(text, params, watch))),
|
|
51
|
-
batch: (statements, options) => guard(() => runCall(isClosed(), options, async (watch) => {
|
|
52
|
-
const { runAtomicBatch } = await import("./ag4c7516.js");
|
|
53
|
-
return runAtomicBatch(session, statements, watch);
|
|
54
|
-
})),
|
|
55
|
-
cancel() {
|
|
56
|
-
session.cancel();
|
|
57
|
-
},
|
|
58
|
-
async release() {
|
|
59
|
-
if (released)
|
|
60
|
-
return;
|
|
61
|
-
released = true;
|
|
62
|
-
try {
|
|
63
|
-
if (!lost)
|
|
64
|
-
await reset(session, client);
|
|
65
|
-
} finally {
|
|
66
|
-
counters.reserved = Math.max(0, counters.reserved - 1);
|
|
67
|
-
events.removeListener("error", onError);
|
|
68
|
-
client.release(lost);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
async function reset(session, client) {
|
|
74
|
-
const run = (text) => client.query(text);
|
|
75
|
-
if (session.depth() > 0)
|
|
76
|
-
await run("ROLLBACK").catch(() => {
|
|
77
|
-
return;
|
|
78
|
-
});
|
|
79
|
-
try {
|
|
80
|
-
await run(RESET_ALL);
|
|
81
|
-
await run(UNLOCK);
|
|
82
|
-
} catch {
|
|
83
|
-
await run("ROLLBACK").catch(() => {
|
|
84
|
-
return;
|
|
85
|
-
});
|
|
86
|
-
await run(RESET_ALL);
|
|
87
|
-
await run(UNLOCK);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
export {
|
|
91
|
-
checkout
|
|
92
|
-
};
|
package/dist/shared/zy8r7qvz.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
staticNamespace2,
|
|
3
|
-
assertNamespace2,
|
|
4
|
-
normaliseEdges,
|
|
5
|
-
assertProvenance
|
|
6
|
-
} from "./358zsv4r.js";
|
|
7
|
-
import {
|
|
8
|
-
assertIdentifier2,
|
|
9
|
-
fitIdentifier2,
|
|
10
|
-
deterministicName2
|
|
11
|
-
} from "./nfzc5z0w.js";
|
|
12
|
-
import {
|
|
13
|
-
catalogError2
|
|
14
|
-
} from "./52szzakm.js";
|
|
15
|
-
|
|
16
|
-
// src/contracts/catalog/view.ts
|
|
17
|
-
function normaliseViewQuery(query) {
|
|
18
|
-
return query.trim().replace(/;\s*$/, "");
|
|
19
|
-
}
|
|
20
|
-
function viewObject(input) {
|
|
21
|
-
const namespace = input.namespace ?? staticNamespace2("public");
|
|
22
|
-
const columns = readColumns(input.name, input.columns);
|
|
23
|
-
const query = readQuery(input.name, input.query);
|
|
24
|
-
assertNamespace2(namespace);
|
|
25
|
-
assertProvenance(input.provenance);
|
|
26
|
-
const definition = {
|
|
27
|
-
columns,
|
|
28
|
-
query,
|
|
29
|
-
...input.securityInvoker === true ? { securityInvoker: true } : {}
|
|
30
|
-
};
|
|
31
|
-
return {
|
|
32
|
-
kind: "view",
|
|
33
|
-
identity: { kind: "view", namespace, name: input.name },
|
|
34
|
-
owner: input.owner ?? "managed",
|
|
35
|
-
definition,
|
|
36
|
-
dependencies: normaliseEdges(input.dependencies ?? []),
|
|
37
|
-
provenance: input.provenance
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function materializedViewObject(input) {
|
|
41
|
-
const namespace = input.namespace ?? staticNamespace2("public");
|
|
42
|
-
const columns = readColumns(input.name, input.columns);
|
|
43
|
-
const query = readQuery(input.name, input.query);
|
|
44
|
-
assertNamespace2(namespace);
|
|
45
|
-
assertProvenance(input.provenance);
|
|
46
|
-
const definition = {
|
|
47
|
-
columns,
|
|
48
|
-
query,
|
|
49
|
-
...input.refresh === "concurrently" ? { refresh: "concurrently" } : {}
|
|
50
|
-
};
|
|
51
|
-
return {
|
|
52
|
-
kind: "materializedView",
|
|
53
|
-
identity: { kind: "materializedView", namespace, name: input.name },
|
|
54
|
-
owner: input.owner ?? "managed",
|
|
55
|
-
definition,
|
|
56
|
-
dependencies: normaliseEdges(input.dependencies ?? []),
|
|
57
|
-
provenance: input.provenance
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function materializedViewIndex(input) {
|
|
61
|
-
assertNamespace2(input.parent.namespace);
|
|
62
|
-
assertIdentifier2(input.parent.name, "index parent");
|
|
63
|
-
assertProvenance(input.provenance);
|
|
64
|
-
const columns = [...input.columns];
|
|
65
|
-
for (const name of columns)
|
|
66
|
-
assertIdentifier2(name, "index column");
|
|
67
|
-
if (columns.length === 0 && input.expression === undefined) {
|
|
68
|
-
catalogError2("OKM1020", `Index on ${input.parent.name} needs a column or an expression.`);
|
|
69
|
-
}
|
|
70
|
-
const nameKey = input.nameKey ?? (columns.length > 0 ? columns.join("_") : "expr");
|
|
71
|
-
const name = input.name === undefined ? deterministicName2({ parent: input.parent.name, purpose: "index", nameKey }) : fitIdentifier2(input.name);
|
|
72
|
-
const parentView = {
|
|
73
|
-
kind: "materializedView",
|
|
74
|
-
namespace: input.parent.namespace,
|
|
75
|
-
name: input.parent.name
|
|
76
|
-
};
|
|
77
|
-
return {
|
|
78
|
-
kind: "index",
|
|
79
|
-
identity: { kind: "index", parent: input.parent, name },
|
|
80
|
-
owner: input.owner ?? "managed",
|
|
81
|
-
definition: {
|
|
82
|
-
columns,
|
|
83
|
-
unique: input.unique === true,
|
|
84
|
-
nameKey,
|
|
85
|
-
...input.expression !== undefined ? { expression: input.expression } : {},
|
|
86
|
-
...input.predicate !== undefined ? { predicate: input.predicate } : {}
|
|
87
|
-
},
|
|
88
|
-
dependencies: normaliseEdges(input.dependencies ?? [parentView]),
|
|
89
|
-
provenance: input.provenance
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
function readColumns(view, columns) {
|
|
93
|
-
assertIdentifier2(view, "view");
|
|
94
|
-
if (columns.length === 0)
|
|
95
|
-
catalogError2("OKM1020", `View ${view} needs a column.`);
|
|
96
|
-
const seen = new Set;
|
|
97
|
-
return columns.map((column) => {
|
|
98
|
-
assertIdentifier2(column.name, `view ${view} column`);
|
|
99
|
-
if (seen.has(column.name)) {
|
|
100
|
-
catalogError2("OKM1020", `View ${view} lists column ${column.name} twice.`);
|
|
101
|
-
}
|
|
102
|
-
seen.add(column.name);
|
|
103
|
-
if (column.dataType.length === 0 || /[;'"\\]/.test(column.dataType)) {
|
|
104
|
-
catalogError2("OKM1020", `View ${view} column ${column.name} type is not a type name.`);
|
|
105
|
-
}
|
|
106
|
-
return { name: column.name, dataType: column.dataType };
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
function readQuery(view, query) {
|
|
110
|
-
const text = normaliseViewQuery(query);
|
|
111
|
-
if (text.length === 0)
|
|
112
|
-
catalogError2("OKM1020", `View ${view} needs a query.`);
|
|
113
|
-
return text;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export { normaliseViewQuery, viewObject, materializedViewObject, materializedViewIndex };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readClientGenerator
|
|
3
|
+
} from "./rwmrejjz.js";
|
|
1
4
|
import {
|
|
2
5
|
definition,
|
|
3
6
|
rejected,
|
|
@@ -11,9 +14,6 @@ import {
|
|
|
11
14
|
REFERENTIAL_ACTIONS,
|
|
12
15
|
referentialAction
|
|
13
16
|
} from "./4e4c6vq2.js";
|
|
14
|
-
import {
|
|
15
|
-
readClientGenerator
|
|
16
|
-
} from "./rwmrejjz.js";
|
|
17
17
|
|
|
18
18
|
// src/dialects/pg/column.ts
|
|
19
19
|
class ColumnBuilder2 {
|