okmodel 0.5.1 → 0.7.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 -1116
- package/dist/adapters/capabilities.d.ts +3 -0
- package/dist/adapters/failure.d.ts +13 -2
- package/dist/adapters/lazy-errors.d.ts +22 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +54 -3
- package/dist/adapters/pg/bunsql.d.ts +14 -1
- package/dist/adapters/pg/cursor.d.ts +17 -0
- package/dist/adapters/pg/no-inflight-timeout.d.ts +20 -0
- 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 +41 -3
- package/dist/adapters/pg/reserved.d.ts +42 -0
- package/dist/adapters/pg/session.d.ts +0 -18
- package/dist/contracts/catalog/document.d.ts +19 -5
- package/dist/contracts/catalog/object.d.ts +2 -1
- package/dist/contracts/catalog/policy.d.ts +48 -0
- package/dist/contracts/catalog/types.d.ts +25 -1
- package/dist/contracts/catalog/view.d.ts +2 -0
- package/dist/contracts/connection.d.ts +7 -6
- package/dist/contracts/internal.js +1 -1
- package/dist/contracts/location.d.ts +10 -0
- package/dist/dialects/pg/column.d.ts +13 -2
- package/dist/dialects/pg/ddl.d.ts +37 -1
- package/dist/dialects/pg/emit.d.ts +19 -1
- package/dist/dialects/pg/errors.d.ts +32 -1
- package/dist/dialects/pg/ext/citext.js +1 -1
- package/dist/dialects/pg/ext/index.js +1 -1
- package/dist/dialects/pg/ext/pg-trgm.js +1 -1
- package/dist/dialects/pg/filter-parse.d.ts +5 -4
- package/dist/dialects/pg/floor.d.ts +68 -0
- package/dist/dialects/pg/fn/index.js +2 -2
- package/dist/dialects/pg/index.d.ts +8 -2
- package/dist/dialects/pg/index.js +67 -171
- package/dist/dialects/pg/introspect.d.ts +7 -0
- package/dist/dialects/pg/keys.d.ts +11 -8
- package/dist/dialects/pg/model.d.ts +47 -2
- 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/inc.d.ts +2 -2
- 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/owner.d.ts +42 -0
- package/dist/dialects/pg/path-endpoint.d.ts +20 -0
- package/dist/dialects/pg/preset.d.ts +1 -1
- package/dist/dialects/pg/relations.d.ts +100 -3
- package/dist/dialects/pg/role/check.d.ts +3 -0
- package/dist/dialects/pg/role/index.d.ts +71 -6
- package/dist/dialects/pg/role/sql.d.ts +11 -0
- package/dist/dialects/pg/schema.d.ts +33 -3
- package/dist/dialects/pg/table.d.ts +25 -3
- package/dist/dialects/pg/tenancy.d.ts +45 -3
- package/dist/dialects/pg/view/client.d.ts +19 -1
- package/dist/dialects/pg/view/index.d.ts +4 -0
- package/dist/dialects/pg/view/index.js +21 -178
- package/dist/dialects/pg/view/refresh.d.ts +24 -0
- package/dist/runtime/aggregate.d.ts +8 -2
- package/dist/runtime/batch.d.ts +1 -1
- package/dist/runtime/bucket-group.d.ts +70 -0
- package/dist/runtime/conflict.d.ts +24 -6
- package/dist/runtime/drift.d.ts +9 -0
- package/dist/runtime/include.d.ts +0 -8
- package/dist/runtime/inflight.d.ts +14 -0
- package/dist/runtime/page.d.ts +4 -1
- package/dist/runtime/pg/bun.js +12 -5
- package/dist/runtime/pg/pg.js +5 -5
- package/dist/runtime/pg/pglite.d.ts +1 -0
- package/dist/runtime/pg/pglite.js +9 -8
- package/dist/runtime/pg/postgresjs.js +5 -5
- package/dist/runtime/plan.d.ts +113 -15
- package/dist/runtime/predicate.d.ts +19 -0
- package/dist/runtime/read-stream.d.ts +13 -16
- package/dist/runtime/result-name.d.ts +17 -0
- package/dist/runtime/safety/index.js +1 -1
- 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/sync.d.ts +70 -0
- package/dist/runtime/tenancy/composite.d.ts +26 -0
- package/dist/runtime/tenancy/context.d.ts +16 -0
- package/dist/runtime/tenancy/index.d.ts +9 -5
- package/dist/runtime/tenancy/index.js +1511 -38
- package/dist/runtime/tenancy/path.d.ts +87 -0
- package/dist/runtime/tenancy/rls.d.ts +67 -0
- package/dist/runtime/tenancy/via.d.ts +22 -0
- package/dist/runtime/text-search.d.ts +20 -0
- package/dist/runtime/traits/index.d.ts +80 -0
- package/dist/runtime/traits/index.js +187 -17
- package/dist/runtime/tree.d.ts +38 -0
- package/dist/runtime/types.d.ts +231 -23
- 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 +55 -3
- package/dist/shared/{krxx77g0.js → 14vx95q4.js} +12 -18
- package/dist/shared/1est4ezg.js +313 -0
- package/dist/shared/{4az561fn.js → 1qa0qajz.js} +8 -23
- package/dist/shared/1w508jbr.js +1611 -0
- package/dist/shared/2c13q96h.js +18 -0
- package/dist/shared/2d3xq4ps.js +9 -0
- package/dist/shared/2shdbn8q.js +23 -0
- package/dist/shared/{t4tbsy9h.js → 358zsv4r.js} +1 -1
- package/dist/shared/3v7t1yrv.js +208 -0
- package/dist/shared/5e3tf63j.js +220 -0
- package/dist/shared/5fe3kbsh.js +10 -0
- package/dist/shared/5v3xf80k.js +37 -0
- package/dist/shared/{51mvgj8w.js → 63qtkrca.js} +130 -3
- package/dist/shared/{gbtcc2d7.js → 67txcrcw.js} +62 -66
- package/dist/shared/79dt02vc.js +12 -0
- package/dist/shared/{v36c5g6p.js → 7k9grvf6.js} +407 -14
- package/dist/shared/7kms6fvj.js +20 -0
- package/dist/shared/7mnme5tn.js +8 -0
- package/dist/shared/7n7ddwt4.js +6 -0
- package/dist/shared/{87jvvhnt.js → 81ebdx9p.js} +48 -68
- package/dist/shared/{szm0cksa.js → 8skf0cam.js} +34 -6
- package/dist/shared/{gjthds9j.js → 9628a9xt.js} +1 -1
- package/dist/shared/9a4ae4p8.js +31 -0
- package/dist/shared/{8xsbagad.js → 9s0ypp87.js} +88 -7
- package/dist/shared/9y3mmmh1.js +436 -0
- package/dist/shared/ab9gmbwy.js +213 -0
- package/dist/shared/{sycnx8gt.js → ax7qv55k.js} +18 -8
- package/dist/shared/{f5cw5q5r.js → aytqh5y2.js} +6 -4
- package/dist/shared/{fancm5pt.js → b5pftnn2.js} +138 -15
- package/dist/shared/{efmy2gcg.js → b76b8d95.js} +2 -2
- package/dist/shared/bdk4sty6.js +58 -0
- package/dist/shared/{32zqc1dw.js → bg3rym3g.js} +63 -32
- package/dist/shared/{0t22wwh1.js → bm22fvzr.js} +16 -14
- package/dist/shared/bz84tkzm.js +342 -0
- package/dist/shared/{31vm914h.js → cm3w0ywp.js} +15 -16
- package/dist/shared/cn957f8d.js +179 -0
- package/dist/shared/{pf0d8f77.js → cnkky55j.js} +25 -14
- package/dist/shared/{5fqx9yh4.js → dk8v79p3.js} +3 -1
- package/dist/shared/{nkaxvt9q.js → dkxgzaqd.js} +224 -19
- package/dist/shared/dzj09cye.js +10 -0
- package/dist/shared/{4m9fn52z.js → ed0b8k4s.js} +1 -1
- package/dist/shared/{z2rnngj4.js → ek2wt2dz.js} +8 -5
- package/dist/shared/exn3sd90.js +359 -0
- package/dist/shared/g6evj1j3.js +66 -0
- package/dist/shared/ga9j92qj.js +25 -0
- package/dist/shared/{qv2ydck9.js → gs74dbj5.js} +651 -76
- package/dist/shared/gzaveazc.js +285 -0
- package/dist/shared/{8rsy3hxz.js → h15jx9bc.js} +1 -1
- package/dist/shared/{dyj86cmj.js → hyh73qk6.js} +3 -3
- package/dist/shared/je4axnm8.js +22 -0
- package/dist/shared/{ycatkxmq.js → jgqj11w4.js} +1 -1
- package/dist/shared/{6qd27mx0.js → jvd0mqag.js} +5 -5
- package/dist/shared/jznfax0y.js +155 -0
- package/dist/shared/{cgbamx3e.js → kb2sdhfb.js} +7 -4
- package/dist/shared/{ps7a6h14.js → kr0jzbw2.js} +12 -8
- package/dist/shared/{janx09m5.js → ktz42yez.js} +20 -8
- package/dist/shared/{gde73es6.js → m6p12kbr.js} +56 -55
- package/dist/shared/{r6nwkxnt.js → m7n9h2a5.js} +4 -4
- package/dist/shared/{672t5vym.js → mss6ctgv.js} +2 -2
- package/dist/shared/{nxdp2ze3.js → mtaszv5a.js} +144 -12
- package/dist/shared/n816peh1.js +45 -0
- package/dist/shared/nbw1z4yd.js +18 -0
- package/dist/shared/{cctw17hj.js → p6qc5gcp.js} +38 -34
- package/dist/shared/{6rk2gen5.js → pbp1ss85.js} +20 -17
- package/dist/shared/pt94kz7f.js +6 -0
- package/dist/shared/{wq9n6pwr.js → pz6rj8ay.js} +82 -9
- package/dist/shared/q5c6ngn3.js +13 -0
- package/dist/shared/{8bwbwy8h.js → qq3899ht.js} +128 -18
- package/dist/shared/{8ktwd3rh.js → r3j8s5y0.js} +1 -1
- package/dist/shared/rhs3xe4k.js +7 -0
- package/dist/shared/{ntneex2a.js → rpycarcr.js} +6 -6
- package/dist/shared/{sdc7r2ww.js → rs73fca9.js} +8 -8
- package/dist/shared/{tm5ab8we.js → sfz1ksn6.js} +7 -4
- package/dist/shared/{6mnp99hx.js → svncdeh5.js} +16 -12
- package/dist/shared/{hf22e0wt.js → tbrvgw6z.js} +62 -42
- package/dist/shared/te5as7z7.js +622 -0
- package/dist/shared/{ga3sfy93.js → tsvww22q.js} +535 -200
- package/dist/shared/{47x8x9ze.js → ttsqgp4p.js} +20 -13
- package/dist/shared/{x72jb7ad.js → v8g1vgv8.js} +1 -1
- package/dist/shared/vb6qfyve.js +152 -0
- package/dist/shared/{r2sp8hrc.js → vczs8gd4.js} +22 -13
- package/dist/shared/{1g0drakv.js → vqrjpcqn.js} +145 -3
- package/dist/shared/{2pqx26h8.js → w72kgg4q.js} +31 -22
- package/dist/shared/{96qcj21c.js → w79hsckn.js} +16 -51
- package/dist/shared/wa07eas9.js +730 -0
- package/dist/shared/{k8v5v5wj.js → x933k9a3.js} +75 -34
- package/dist/shared/{cr74e96e.js → xhfsfkgk.js} +62 -28
- package/dist/shared/xjk7hnn5.js +272 -0
- package/dist/shared/{5enne4ma.js → xnxsed62.js} +66 -113
- package/dist/shared/xqve9598.js +53 -0
- package/dist/shared/{9x25fxhc.js → y34a8714.js} +1 -1
- package/dist/shared/{k7dwkhvq.js → y6jdds7g.js} +4 -1
- package/dist/shared/y6njgyda.js +249 -0
- package/dist/shared/{c9z5g0fm.js → ywr8hmey.js} +5 -2
- package/dist/shared/{g7ez901n.js → ywspezzx.js} +1 -1
- package/dist/shared/z7s6fpxv.js +62 -0
- package/dist/shared/{n7mcc1gk.js → zchaghkf.js} +4 -3
- package/dist/shared/{9m80mkac.js → ze4hxsmy.js} +1 -1
- package/dist/shared/zm0ptry0.js +40 -0
- package/dist/shared/{nsva2a6b.js → znm0bpp5.js} +3 -0
- package/dist/shared/zp9fmend.js +145 -0
- package/dist/shared/{y005b761.js → zy8r7qvz.js} +6 -2
- package/dist/tooling/cli.js +41 -15
- package/dist/tooling/migrate/apply.d.ts +14 -0
- package/dist/tooling/migrate/check.d.ts +3 -4
- package/dist/tooling/migrate/classify.d.ts +4 -0
- package/dist/tooling/migrate/config.d.ts +3 -2
- package/dist/tooling/migrate/engine.d.ts +3 -2
- package/dist/tooling/migrate/files.d.ts +11 -1
- package/dist/tooling/migrate/index.js +14 -14
- package/dist/tooling/migrate/lint.d.ts +1 -1
- package/dist/tooling/migrate/lost.d.ts +28 -0
- package/dist/tooling/migrate/paths.d.ts +14 -0
- package/dist/tooling/migrate/plan.d.ts +6 -3
- package/dist/tooling/migrate/runner.d.ts +25 -0
- package/dist/tooling/migrate/sandbox.d.ts +57 -0
- package/dist/tooling/migrate/sql-lex.d.ts +20 -3
- package/dist/tooling/migrate/text.d.ts +42 -0
- package/dist/tooling/node-version.d.ts +21 -0
- package/dist/tooling/testing/facts.d.ts +33 -5
- package/dist/tooling/testing/index.d.ts +1 -1
- package/dist/tooling/testing/index.js +3 -3
- package/dist/tooling/testing/isolation.d.ts +11 -5
- package/package.json +8 -3
- package/dist/shared/7m88x3e9.js +0 -45
- package/dist/shared/7zwwyh0v.js +0 -448
- package/dist/shared/aj2qxyhj.js +0 -90
- package/dist/shared/caw8b9d8.js +0 -204
- package/dist/shared/jwtxdj06.js +0 -76
- package/dist/shared/kfjp0gck.js +0 -212
- package/dist/shared/q58y17hy.js +0 -21
- package/dist/shared/qm7cdtvr.js +0 -912
- package/dist/shared/r8x5qhd7.js +0 -86
- package/dist/shared/zqrnhwsq.js +0 -31
|
@@ -1,24 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
UUIDV7_POSTGRES,
|
|
3
|
+
isPostgresMajor,
|
|
4
|
+
parsePostgresFloor,
|
|
5
|
+
formatPostgresFloor,
|
|
6
|
+
minPostgresDefinition,
|
|
7
|
+
uuidv7NeedsPostgres
|
|
8
|
+
} from "./ga9j92qj.js";
|
|
1
9
|
import {
|
|
2
10
|
catalog,
|
|
3
11
|
enumType,
|
|
4
12
|
sameEnumLabels
|
|
5
|
-
} from "./
|
|
6
|
-
import {
|
|
7
|
-
snakeCase,
|
|
8
|
-
emittedTypeName,
|
|
9
|
-
rejectLater
|
|
10
|
-
} from "./ntneex2a.js";
|
|
13
|
+
} from "./ywspezzx.js";
|
|
11
14
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./
|
|
15
|
+
isRelationCall
|
|
16
|
+
} from "./exn3sd90.js";
|
|
14
17
|
import {
|
|
15
18
|
encodeText,
|
|
16
19
|
decodeText
|
|
17
|
-
} from "./
|
|
20
|
+
} from "./ed0b8k4s.js";
|
|
21
|
+
import {
|
|
22
|
+
snakeCase,
|
|
23
|
+
emittedTypeName,
|
|
24
|
+
rejectLater
|
|
25
|
+
} from "./rpycarcr.js";
|
|
18
26
|
import {
|
|
19
27
|
ColumnBuilder2,
|
|
20
28
|
formatType
|
|
21
|
-
} from "./
|
|
29
|
+
} from "./ywr8hmey.js";
|
|
22
30
|
import {
|
|
23
31
|
definition,
|
|
24
32
|
unavailable
|
|
@@ -26,6 +34,9 @@ import {
|
|
|
26
34
|
import {
|
|
27
35
|
quoteLiteral
|
|
28
36
|
} from "./94ez8kzh.js";
|
|
37
|
+
import {
|
|
38
|
+
withLocation
|
|
39
|
+
} from "./y6jdds7g.js";
|
|
29
40
|
import {
|
|
30
41
|
staticNamespace2,
|
|
31
42
|
table3,
|
|
@@ -34,7 +45,7 @@ import {
|
|
|
34
45
|
constraint2,
|
|
35
46
|
sequence2,
|
|
36
47
|
compareText
|
|
37
|
-
} from "./
|
|
48
|
+
} from "./358zsv4r.js";
|
|
38
49
|
import {
|
|
39
50
|
assertIdentifier2,
|
|
40
51
|
fitIdentifier2,
|
|
@@ -49,85 +60,6 @@ import {
|
|
|
49
60
|
readClientGenerator
|
|
50
61
|
} from "./rwmrejjz.js";
|
|
51
62
|
|
|
52
|
-
// src/dialects/pg/through.ts
|
|
53
|
-
var emit = (planner, schema, relation, child, sink, parent, alias, depth) => {
|
|
54
|
-
const through = relation.through;
|
|
55
|
-
const join = through === undefined ? undefined : planner.indexes(schema).get(through.table);
|
|
56
|
-
if (through === undefined || join === undefined) {
|
|
57
|
-
return catalogError2("OKM1020", `Relation ${relation.name} names a join table that is not in the schema.`);
|
|
58
|
-
}
|
|
59
|
-
const { quote } = planner;
|
|
60
|
-
const joinAlias = `j${alias}`;
|
|
61
|
-
sink.mark(`via:${through.table}`);
|
|
62
|
-
sink.text(`${quote(join.model.sql)} ${joinAlias} join ${quote(child.model.sql)} ${alias} on `);
|
|
63
|
-
for (let index = 0;index < through.local.length; index += 1) {
|
|
64
|
-
const local = through.local[index];
|
|
65
|
-
const remote = through.remote[index];
|
|
66
|
-
if (local === undefined || remote === undefined)
|
|
67
|
-
continue;
|
|
68
|
-
if (index > 0)
|
|
69
|
-
sink.text(" and ");
|
|
70
|
-
sink.text(`${alias}.${quote(remote)} = ${joinAlias}.${quote(local)}`);
|
|
71
|
-
}
|
|
72
|
-
sink.text(" where ");
|
|
73
|
-
planner.join(sink, parent, joinAlias, relation);
|
|
74
|
-
planner.where(schema, join, undefined, sink, joinAlias, depth + 1, true);
|
|
75
|
-
};
|
|
76
|
-
function resolveThrough(scope, table, through, from, to) {
|
|
77
|
-
for (const name of [table, through]) {
|
|
78
|
-
if (!scope.tables.includes(name)) {
|
|
79
|
-
throwNamed2("OKM1020", name, scope.tables, `Relation ${scope.owner}.${scope.name} names ${name}, which is not in the schema. Accepted names: ${scope.tables.join(", ")}.`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const toOwner = pick(scope, through, scope.owner, from, `${scope.owner}.${scope.name}`, "from");
|
|
83
|
-
const toTable = pick(scope, through, table, to, `${scope.owner}.${scope.name}`, "to");
|
|
84
|
-
if (toOwner === toTable) {
|
|
85
|
-
catalogError2("OKM1021", `Relation ${scope.owner}.${scope.name} uses ${toOwner.fromField} on ${through} for both ends. Pass from and to.`);
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
name: scope.name,
|
|
89
|
-
kind: "many",
|
|
90
|
-
table,
|
|
91
|
-
local: toOwner.remote,
|
|
92
|
-
remote: toOwner.local,
|
|
93
|
-
through: { table: through, local: toTable.local, remote: toTable.remote, emit }
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function pick(scope, through, target, field, label, end) {
|
|
97
|
-
const matches = scope.edges.filter((edge) => edge.fromTable === through && edge.toTable === target && (field === undefined || edge.fromField === field));
|
|
98
|
-
const [only] = matches;
|
|
99
|
-
if (matches.length === 1 && only !== undefined)
|
|
100
|
-
return only;
|
|
101
|
-
const fields = matches.map((edge) => edge.fromField).sort();
|
|
102
|
-
catalogError2("OKM1021", `Relation ${label} through ${through} is ambiguous at ${end}. Accepted columns: ${fields.length === 0 ? "(none)" : fields.join(", ")}.`);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// src/dialects/pg/relations.ts
|
|
106
|
-
function one2(table, field) {
|
|
107
|
-
return { kind: "one", table, field };
|
|
108
|
-
}
|
|
109
|
-
function many2(table, field) {
|
|
110
|
-
return { kind: "many", table, field };
|
|
111
|
-
}
|
|
112
|
-
function isRelationCall(value) {
|
|
113
|
-
if (typeof value !== "object" || value === null)
|
|
114
|
-
return false;
|
|
115
|
-
if (!("kind" in value) || !("table" in value))
|
|
116
|
-
return false;
|
|
117
|
-
const kind = value.kind;
|
|
118
|
-
return (kind === "one" || kind === "many") && typeof value.table === "string";
|
|
119
|
-
}
|
|
120
|
-
function manyThrough2(table, options) {
|
|
121
|
-
const { through, from, to } = options;
|
|
122
|
-
return {
|
|
123
|
-
kind: "many",
|
|
124
|
-
table,
|
|
125
|
-
field: undefined,
|
|
126
|
-
through,
|
|
127
|
-
resolve: (scope) => resolveThrough(scope, table, through, from, to)
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
63
|
// src/dialects/pg/compile.ts
|
|
132
64
|
function compileColumn(builder, input) {
|
|
133
65
|
const state = builder.state;
|
|
@@ -212,7 +144,7 @@ function readTenancy(value) {
|
|
|
212
144
|
definition("schema() tenancy must be columnTenancy() from okmodel/tenancy.");
|
|
213
145
|
}
|
|
214
146
|
const record = value;
|
|
215
|
-
if (
|
|
147
|
+
if (typeof record.rewrite !== "function") {
|
|
216
148
|
definition("schema() tenancy must be columnTenancy() from okmodel/tenancy.");
|
|
217
149
|
}
|
|
218
150
|
return value;
|
|
@@ -225,6 +157,7 @@ var SCHEMA_KNOWN = new Set([
|
|
|
225
157
|
"defaults",
|
|
226
158
|
"extensions",
|
|
227
159
|
"functions",
|
|
160
|
+
"minPostgres",
|
|
228
161
|
"requires",
|
|
229
162
|
"tables",
|
|
230
163
|
"tenancy",
|
|
@@ -254,7 +187,7 @@ function schema2(config) {
|
|
|
254
187
|
const hooks = collectHooks(tenancy, schemaTraits, config.tables, config.views);
|
|
255
188
|
const types = readTypes(config.types);
|
|
256
189
|
const codecs = readCodecs(config.codecs);
|
|
257
|
-
const requires =
|
|
190
|
+
const requires = readFloor(config.minPostgres, config.requires);
|
|
258
191
|
const idDefault = readIdDefault(config.defaults);
|
|
259
192
|
const namespace = staticNamespace2("public");
|
|
260
193
|
const accepted = acceptTables(config.tables);
|
|
@@ -279,8 +212,9 @@ function schema2(config) {
|
|
|
279
212
|
compileForeignKeys(item, byName, accepted, jobs, edges);
|
|
280
213
|
}
|
|
281
214
|
const model = {};
|
|
215
|
+
const scopeFields = tenancy === undefined ? undefined : tenancy.keys !== undefined ? tenancy.keys : [tenancy.key];
|
|
282
216
|
for (const item of prepared) {
|
|
283
|
-
model[item.tsName] = tableModel(item, edges, byName, accepted);
|
|
217
|
+
model[item.tsName] = tableModel(item, edges, byName, accepted, scopeFields);
|
|
284
218
|
}
|
|
285
219
|
bindViews(config.views, model, tenancy, tables, casing);
|
|
286
220
|
let document;
|
|
@@ -557,7 +491,7 @@ function compileTable(item, namespace, casing, codecs, requires, idDefault, jobs
|
|
|
557
491
|
references: column.state.references,
|
|
558
492
|
encode: column.state.encode,
|
|
559
493
|
decode: decode === decodeText ? undefined : decode,
|
|
560
|
-
hidden: column.state.hidden,
|
|
494
|
+
hidden: column.state.filterable === true ? "filter" : column.state.hidden,
|
|
561
495
|
sensitive: column.state.sensitive,
|
|
562
496
|
guarded: column.state.guarded,
|
|
563
497
|
writable: column.state.guarded !== true && column.state.omitWrite !== true && column.state.generated === undefined,
|
|
@@ -578,7 +512,7 @@ function compileTable(item, namespace, casing, codecs, requires, idDefault, jobs
|
|
|
578
512
|
columnPrimary.push(prepared.sqlName);
|
|
579
513
|
}
|
|
580
514
|
if (column.state.defaultSql === "uuidv7()") {
|
|
581
|
-
refuseUuidV7(
|
|
515
|
+
refuseUuidV7(requires);
|
|
582
516
|
}
|
|
583
517
|
const labels = column.state.enumLabels;
|
|
584
518
|
if (labels !== undefined) {
|
|
@@ -934,7 +868,7 @@ function readCodecs(codecs) {
|
|
|
934
868
|
}
|
|
935
869
|
return { bigint, numeric, timestamps };
|
|
936
870
|
}
|
|
937
|
-
function tableModel(item, edges, byName, accepted) {
|
|
871
|
+
function tableModel(item, edges, byName, accepted, scopeFields) {
|
|
938
872
|
const primary = [];
|
|
939
873
|
for (const sqlName of item.primary) {
|
|
940
874
|
const column = item.bySql.get(sqlName);
|
|
@@ -967,7 +901,7 @@ function tableModel(item, edges, byName, accepted) {
|
|
|
967
901
|
primary,
|
|
968
902
|
uniques: item.uniques,
|
|
969
903
|
columns,
|
|
970
|
-
relations: resolveRelations(item, edges, byName, accepted),
|
|
904
|
+
relations: resolveRelations(item, edges, byName, accepted, scopeFields),
|
|
971
905
|
...conceal ? { conceal: true } : {},
|
|
972
906
|
...item.traits !== undefined ? { traits: item.traits } : {},
|
|
973
907
|
...item.provenance.source !== undefined ? { source: item.provenance.source } : {},
|
|
@@ -975,10 +909,11 @@ function tableModel(item, edges, byName, accepted) {
|
|
|
975
909
|
...item.presets !== undefined ? { presets: item.presets } : {}
|
|
976
910
|
};
|
|
977
911
|
}
|
|
978
|
-
function resolveRelations(item, edges, byName, accepted) {
|
|
912
|
+
function resolveRelations(item, edges, byName, accepted, scopeFields) {
|
|
979
913
|
const raw = item.relationOptions;
|
|
980
914
|
if (raw === undefined)
|
|
981
915
|
return [];
|
|
916
|
+
const describe = (table) => byName.get(table);
|
|
982
917
|
const record = raw;
|
|
983
918
|
const names = Object.keys(record);
|
|
984
919
|
const resolved = [];
|
|
@@ -989,11 +924,18 @@ function resolveRelations(item, edges, byName, accepted) {
|
|
|
989
924
|
seen.add(name);
|
|
990
925
|
const call = record[name];
|
|
991
926
|
if (!isRelationCall(call)) {
|
|
992
|
-
unavailable(`Table ${item.tsName} relation ${name} is not
|
|
927
|
+
unavailable(`Table ${item.tsName} relation ${name} is not a relation. one(), many(), manyThrough(), morph(), and morphMany() are accepted.`);
|
|
993
928
|
}
|
|
994
929
|
const own = call.resolve;
|
|
995
930
|
if (own !== undefined) {
|
|
996
|
-
resolved.push(own({
|
|
931
|
+
resolved.push(own({
|
|
932
|
+
owner: item.tsName,
|
|
933
|
+
name,
|
|
934
|
+
edges,
|
|
935
|
+
tables: accepted,
|
|
936
|
+
describe,
|
|
937
|
+
...scopeFields === undefined ? {} : { scopeFields }
|
|
938
|
+
}));
|
|
997
939
|
continue;
|
|
998
940
|
}
|
|
999
941
|
if (!byName.has(call.table)) {
|
|
@@ -1078,21 +1020,32 @@ function readIdDefault(defaults) {
|
|
|
1078
1020
|
return { kind: "client", fill };
|
|
1079
1021
|
definition('schema() defaults.id must be "uuidv7", "uuidv4", or a client generator.');
|
|
1080
1022
|
}
|
|
1081
|
-
function refuseUuidV7(
|
|
1082
|
-
const declared =
|
|
1083
|
-
if (!(declared > 0) || declared >=
|
|
1023
|
+
function refuseUuidV7(requires) {
|
|
1024
|
+
const declared = parsePostgresFloor(requires?.postgres);
|
|
1025
|
+
if (!(declared > 0) || declared >= UUIDV7_POSTGRES)
|
|
1084
1026
|
return;
|
|
1085
|
-
|
|
1027
|
+
const sentence = uuidv7NeedsPostgres();
|
|
1028
|
+
throw new OkmError2("OKM1812", sentence, { fix: { summary: sentence } });
|
|
1086
1029
|
}
|
|
1087
|
-
function
|
|
1088
|
-
if (requires
|
|
1089
|
-
|
|
1090
|
-
}
|
|
1091
|
-
const postgres = requires.postgres;
|
|
1092
|
-
if (postgres !== undefined && postgres.length === 0) {
|
|
1093
|
-
definition("schema() requires.postgres must be a version range such as >=17.");
|
|
1030
|
+
function readFloor(minPostgres, requires) {
|
|
1031
|
+
if (minPostgres !== undefined && requires !== undefined) {
|
|
1032
|
+
definition("minPostgres or requires.postgres, not both.");
|
|
1094
1033
|
}
|
|
1095
|
-
|
|
1034
|
+
if (minPostgres === undefined && requires === undefined)
|
|
1035
|
+
return;
|
|
1036
|
+
let major = minPostgres;
|
|
1037
|
+
if (minPostgres === undefined) {
|
|
1038
|
+
if (typeof requires !== "object" || requires === null || Array.isArray(requires)) {
|
|
1039
|
+
definition(minPostgresDefinition());
|
|
1040
|
+
}
|
|
1041
|
+
const postgres = requires.postgres;
|
|
1042
|
+
if (postgres === undefined)
|
|
1043
|
+
return {};
|
|
1044
|
+
major = typeof postgres === "string" ? parsePostgresFloor(postgres) : NaN;
|
|
1045
|
+
}
|
|
1046
|
+
if (!isPostgresMajor(major))
|
|
1047
|
+
definition(minPostgresDefinition());
|
|
1048
|
+
return { postgres: formatPostgresFloor(major) };
|
|
1096
1049
|
}
|
|
1097
1050
|
function readIndex(tableName, call) {
|
|
1098
1051
|
if (call.columns.length === 0) {
|
|
@@ -1127,4 +1080,4 @@ function list(names) {
|
|
|
1127
1080
|
return names.length === 0 ? "(none)" : names.join(", ");
|
|
1128
1081
|
}
|
|
1129
1082
|
|
|
1130
|
-
export {
|
|
1083
|
+
export { schema2, addSchemaHook };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OkmError2
|
|
3
|
+
} from "./52szzakm.js";
|
|
4
|
+
|
|
5
|
+
// src/dialects/pg/owner.ts
|
|
6
|
+
var MARKS = new WeakMap;
|
|
7
|
+
function withOwner2(table, owner) {
|
|
8
|
+
if (owner !== "external" && owner !== "ignored") {
|
|
9
|
+
throw new OkmError2("invalid", `Table owner ${String(owner)} is not external or ignored.`, {
|
|
10
|
+
kind: "invalid",
|
|
11
|
+
fix: { summary: "Pass external or ignored. Omit the mark for a managed table." }
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
MARKS.set(table, owner);
|
|
15
|
+
return table;
|
|
16
|
+
}
|
|
17
|
+
function tableOwner(table) {
|
|
18
|
+
return MARKS.get(table);
|
|
19
|
+
}
|
|
20
|
+
function stampOwnership(source, marks) {
|
|
21
|
+
if (marks.size === 0)
|
|
22
|
+
return source;
|
|
23
|
+
let changed = false;
|
|
24
|
+
const objects = source.objects.map((object) => {
|
|
25
|
+
const owner = ownerFor(object, marks);
|
|
26
|
+
if (owner === undefined || object.owner === owner)
|
|
27
|
+
return object;
|
|
28
|
+
changed = true;
|
|
29
|
+
return { ...object, owner };
|
|
30
|
+
});
|
|
31
|
+
if (!changed)
|
|
32
|
+
return source;
|
|
33
|
+
return { version: source.version, objects };
|
|
34
|
+
}
|
|
35
|
+
function ownerFor(object, marks) {
|
|
36
|
+
if (object.kind === "table")
|
|
37
|
+
return marks.get(object.identity.name);
|
|
38
|
+
if (object.kind === "column" || object.kind === "index" || object.kind === "constraint" || object.kind === "trigger" || object.kind === "policy") {
|
|
39
|
+
return marks.get(object.identity.parent.name);
|
|
40
|
+
}
|
|
41
|
+
if (object.kind === "sequence") {
|
|
42
|
+
for (const edge of object.dependencies) {
|
|
43
|
+
if (edge.target.kind !== "table")
|
|
44
|
+
continue;
|
|
45
|
+
const owner = marks.get(edge.target.name);
|
|
46
|
+
if (owner !== undefined)
|
|
47
|
+
return owner;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { withOwner2, tableOwner, stampOwnership };
|
|
@@ -4,9 +4,12 @@ function callerLocation(skip) {
|
|
|
4
4
|
`);
|
|
5
5
|
if (lines === undefined)
|
|
6
6
|
return;
|
|
7
|
+
return locationFromLines(lines, skip);
|
|
8
|
+
}
|
|
9
|
+
function locationFromLines(lines, skip) {
|
|
7
10
|
let left = skip;
|
|
8
11
|
for (const line of lines) {
|
|
9
|
-
const slash = line.lastIndexOf("/");
|
|
12
|
+
const slash = Math.max(line.lastIndexOf("/"), line.lastIndexOf("\\"));
|
|
10
13
|
if (slash < 0)
|
|
11
14
|
continue;
|
|
12
15
|
const tail = line.slice(slash + 1);
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import {
|
|
2
|
+
stack2
|
|
3
|
+
} from "./mss6ctgv.js";
|
|
4
|
+
import {
|
|
5
|
+
updateSliceBody2,
|
|
6
|
+
rejectDuplicateTargets2,
|
|
7
|
+
emitSet2,
|
|
8
|
+
Sql2,
|
|
9
|
+
writeSet2,
|
|
10
|
+
rejectMixedSets2,
|
|
11
|
+
readClaim2,
|
|
12
|
+
rejectUpdateKeys2,
|
|
13
|
+
requireFilter2,
|
|
14
|
+
returningOption2,
|
|
15
|
+
expectOf2,
|
|
16
|
+
allowSet2,
|
|
17
|
+
noteGuarded2
|
|
18
|
+
} from "./1w508jbr.js";
|
|
19
|
+
import {
|
|
20
|
+
emitWhere,
|
|
21
|
+
projectExpr,
|
|
22
|
+
quote,
|
|
23
|
+
isRecord,
|
|
24
|
+
fail2
|
|
25
|
+
} from "./67txcrcw.js";
|
|
26
|
+
|
|
27
|
+
// src/runtime/version.ts
|
|
28
|
+
function planVersioned(schema, table, input, options, mods) {
|
|
29
|
+
if (mods.all !== undefined) {
|
|
30
|
+
fail2("OKM1120", `update on ${table.model.name} cannot use .all() with versioned().`, "Pass a per-row list with the version you read for each row.");
|
|
31
|
+
}
|
|
32
|
+
const allow = allowSet2(table, options.allow);
|
|
33
|
+
noteGuarded2(table, allow, "update");
|
|
34
|
+
const column = versionColumn(table);
|
|
35
|
+
const returning = returningOption2(table, options.returning);
|
|
36
|
+
const expect = expectOf2(options, mods);
|
|
37
|
+
if (Array.isArray(input) && input.length === 0) {
|
|
38
|
+
return {
|
|
39
|
+
statements: [],
|
|
40
|
+
outputs: outputsOf(undefined),
|
|
41
|
+
shape: "count",
|
|
42
|
+
expect,
|
|
43
|
+
versioned: { fields: [], sent: [] }
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const rows = readRows(schema, table, input, allow, mods, column);
|
|
47
|
+
const fields = writtenFields(rows);
|
|
48
|
+
const sent = rows.map((row) => row.version);
|
|
49
|
+
const claim = Array.isArray(input) ? undefined : isRecord(input) ? readClaim2(input) : undefined;
|
|
50
|
+
const statement = claim !== undefined ? claimStatement(schema, table, rows[0], claim, column, returning) : targetStatement(schema, table, rows, column, returning);
|
|
51
|
+
const width = statement.params?.length ?? 0;
|
|
52
|
+
if (width > 30000) {
|
|
53
|
+
fail2("OKM1120", `update on ${table.model.name} is too large to check version in one statement.`, "Split the list.");
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
statements: [statement],
|
|
57
|
+
outputs: outputsOf(returning),
|
|
58
|
+
shape: returning === undefined ? "count" : "rows",
|
|
59
|
+
expect,
|
|
60
|
+
versioned: { fields, sent }
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function versionColumn(table) {
|
|
64
|
+
const column = table.columns.get("version");
|
|
65
|
+
if (column === undefined) {
|
|
66
|
+
fail2("OKM1120", `Table ${table.model.name} is versioned and has no version column.`);
|
|
67
|
+
}
|
|
68
|
+
return column;
|
|
69
|
+
}
|
|
70
|
+
function readRows(schema, table, input, allow, mods, column) {
|
|
71
|
+
if (Array.isArray(input)) {
|
|
72
|
+
if (input.length === 0)
|
|
73
|
+
fail2("OKM1120", "update set is empty.");
|
|
74
|
+
const rows = input.map((item) => readRow(schema, table, item, allow, mods, column, true));
|
|
75
|
+
rejectDuplicateTargets2(table, rows);
|
|
76
|
+
rejectMixedSets2(rows);
|
|
77
|
+
return rows;
|
|
78
|
+
}
|
|
79
|
+
return [readRow(schema, table, input, allow, mods, column, false)];
|
|
80
|
+
}
|
|
81
|
+
function readRow(schema, table, input, allow, mods, column, row) {
|
|
82
|
+
if (!isRecord(input))
|
|
83
|
+
fail2("OKM1121", "update expects { where, set, version } or a list of rows.");
|
|
84
|
+
rejectUpdateKeys2(input, row);
|
|
85
|
+
if (!Object.hasOwn(input, "version")) {
|
|
86
|
+
fail2("OKM1120", `update on ${table.model.name} needs the version you read.`, "Pass version from the row you read. If this write conflicts, reread and retry.");
|
|
87
|
+
}
|
|
88
|
+
const version = readVersion(input.version, table.model.name, column);
|
|
89
|
+
const set = writeSet2(table, input.set, allow, schema.tenancy);
|
|
90
|
+
if (Object.keys(set).length === 0)
|
|
91
|
+
fail2("OKM1120", "update set is empty.");
|
|
92
|
+
refusePath(schema, table, set);
|
|
93
|
+
const where = input.where !== undefined ? input.where : input.id !== undefined ? { id: input.id } : undefined;
|
|
94
|
+
requireFilter2(table, where, mods, "update");
|
|
95
|
+
return { where: stack2(where, mods.presets), set, version };
|
|
96
|
+
}
|
|
97
|
+
function readVersion(value, table, column) {
|
|
98
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value)) {
|
|
99
|
+
fail2("OKM1121", `version on ${table} must be an integer.`, "Pass the version you read.");
|
|
100
|
+
}
|
|
101
|
+
column.encode(value);
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
function refusePath(schema, table, set) {
|
|
105
|
+
if (schema.tenancy?.isPath?.(table.model.name) !== true)
|
|
106
|
+
return;
|
|
107
|
+
const field = schema.tenancy.pathOf?.(table.model.name)?.[0]?.localField;
|
|
108
|
+
if (field === undefined || !Object.hasOwn(set, field))
|
|
109
|
+
return;
|
|
110
|
+
fail2("OKM1120", `update on ${table.model.name} cannot change ${field} and check version in one write.`, "Point it at a parent in a later update.");
|
|
111
|
+
}
|
|
112
|
+
function writtenFields(rows) {
|
|
113
|
+
const names = [];
|
|
114
|
+
for (const row of rows) {
|
|
115
|
+
for (const key of Object.keys(row.set))
|
|
116
|
+
if (!names.includes(key))
|
|
117
|
+
names.push(key);
|
|
118
|
+
}
|
|
119
|
+
return names;
|
|
120
|
+
}
|
|
121
|
+
function targetStatement(schema, table, rows, column, returning) {
|
|
122
|
+
const sql = new Sql2;
|
|
123
|
+
sql.text("with ");
|
|
124
|
+
for (let index = 0;index < rows.length; index += 1) {
|
|
125
|
+
const row = rows[index];
|
|
126
|
+
if (row === undefined)
|
|
127
|
+
continue;
|
|
128
|
+
if (index > 0)
|
|
129
|
+
sql.text(", ");
|
|
130
|
+
sql.text("m");
|
|
131
|
+
sql.text(String(index));
|
|
132
|
+
sql.text(" as (select s.ctid as tid, s.tableoid as toid, s.");
|
|
133
|
+
sql.text(quote(column.sql));
|
|
134
|
+
sql.text(" as okm_version from ");
|
|
135
|
+
sql.text(quote(table.model.sql));
|
|
136
|
+
sql.text(" as s");
|
|
137
|
+
emitWhere(schema, table, row.where, sql.sink(), "s", 0);
|
|
138
|
+
sql.text(" for update of s)");
|
|
139
|
+
}
|
|
140
|
+
sql.text(", gate as (select count(*)::int as n from (");
|
|
141
|
+
for (let index = 0;index < rows.length; index += 1) {
|
|
142
|
+
const row = rows[index];
|
|
143
|
+
if (row === undefined)
|
|
144
|
+
continue;
|
|
145
|
+
if (index > 0)
|
|
146
|
+
sql.text(" union all ");
|
|
147
|
+
sql.text("select 1 from m");
|
|
148
|
+
sql.text(String(index));
|
|
149
|
+
sql.text(" where okm_version is distinct from ");
|
|
150
|
+
sql.param(column.encode(row.version), column.dataType);
|
|
151
|
+
}
|
|
152
|
+
sql.text(") as okm_diff), updated as (");
|
|
153
|
+
updateSliceBody2(schema, table, rows, sql, true, {
|
|
154
|
+
afterWhere(body, index) {
|
|
155
|
+
const row = rows[index];
|
|
156
|
+
if (row === undefined)
|
|
157
|
+
return;
|
|
158
|
+
body.text(" and t.");
|
|
159
|
+
body.text(quote(column.sql));
|
|
160
|
+
body.text(" = ");
|
|
161
|
+
body.param(column.encode(row.version), column.dataType);
|
|
162
|
+
},
|
|
163
|
+
afterSet(body) {
|
|
164
|
+
bump(body, column);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
sql.text(" and (select n from gate) = 0");
|
|
168
|
+
closeUpdated(sql, returning, "gate");
|
|
169
|
+
return sql.statement();
|
|
170
|
+
}
|
|
171
|
+
function claimStatement(schema, table, row, limit, column, returning) {
|
|
172
|
+
if (row === undefined)
|
|
173
|
+
fail2("OKM1120", "update set is empty.");
|
|
174
|
+
const sql = new Sql2;
|
|
175
|
+
sql.text("with claimed as (select s.tableoid as toid, s.ctid as tid from ");
|
|
176
|
+
sql.text(quote(table.model.sql));
|
|
177
|
+
sql.text(" as s");
|
|
178
|
+
emitWhere(schema, table, row.where, sql.sink(), "s", 0);
|
|
179
|
+
sql.text(" and s.");
|
|
180
|
+
sql.text(quote(column.sql));
|
|
181
|
+
sql.text(" = ");
|
|
182
|
+
sql.param(column.encode(row.version), column.dataType);
|
|
183
|
+
sql.text(" for update of s skip locked limit ");
|
|
184
|
+
sql.param(String(limit), "integer");
|
|
185
|
+
sql.text("), stale_free as (select 1 as hit from ");
|
|
186
|
+
sql.text(quote(table.model.sql));
|
|
187
|
+
sql.text(" as s");
|
|
188
|
+
emitWhere(schema, table, row.where, sql.sink(), "s", 0);
|
|
189
|
+
sql.text(" and s.");
|
|
190
|
+
sql.text(quote(column.sql));
|
|
191
|
+
sql.text(" is distinct from ");
|
|
192
|
+
sql.param(column.encode(row.version), column.dataType);
|
|
193
|
+
sql.text(" for update of s skip locked limit 1), updated as (update ");
|
|
194
|
+
sql.text(quote(table.model.sql));
|
|
195
|
+
sql.text(" as t set ");
|
|
196
|
+
emitSet2(sql, table, row.set, "t");
|
|
197
|
+
bump(sql, column);
|
|
198
|
+
sql.text(" where (t.tableoid, t.ctid) in (select toid, tid from claimed)");
|
|
199
|
+
closeUpdated(sql, returning, "claim");
|
|
200
|
+
return sql.statement();
|
|
201
|
+
}
|
|
202
|
+
function bump(sql, column) {
|
|
203
|
+
sql.text(", ");
|
|
204
|
+
sql.text(quote(column.sql));
|
|
205
|
+
sql.text(" = t.");
|
|
206
|
+
sql.text(quote(column.sql));
|
|
207
|
+
sql.text(" + 1");
|
|
208
|
+
}
|
|
209
|
+
function closeUpdated(sql, returning, source) {
|
|
210
|
+
const stale = source === "gate" ? "(select n from gate)" : "(case when (select count(*) from updated) > 0 then 0 else (select count(*)::int from stale_free) end)";
|
|
211
|
+
if (returning === undefined || returning.length === 0) {
|
|
212
|
+
sql.text(" returning 1) select ");
|
|
213
|
+
sql.text(stale);
|
|
214
|
+
sql.text(", (select count(*)::int from updated)");
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
sql.text(" returning t.ctid as okm_tid");
|
|
218
|
+
for (let index = 0;index < returning.length; index += 1) {
|
|
219
|
+
const column = returning[index];
|
|
220
|
+
if (column === undefined)
|
|
221
|
+
continue;
|
|
222
|
+
sql.text(", ");
|
|
223
|
+
sql.text(projectExpr(`t.${quote(column.sql)}`, column.dataType));
|
|
224
|
+
sql.text(" as okm_");
|
|
225
|
+
sql.text(String(index));
|
|
226
|
+
}
|
|
227
|
+
sql.text(") select ");
|
|
228
|
+
sql.text(stale);
|
|
229
|
+
sql.text(", case when u.okm_tid is null then 0 else 1 end");
|
|
230
|
+
for (let index = 0;index < returning.length; index += 1) {
|
|
231
|
+
sql.text(", u.okm_");
|
|
232
|
+
sql.text(String(index));
|
|
233
|
+
}
|
|
234
|
+
sql.text(" from (select 1) as okm_one left join updated u on true");
|
|
235
|
+
}
|
|
236
|
+
function outputsOf(columns) {
|
|
237
|
+
const list = columns ?? [];
|
|
238
|
+
return {
|
|
239
|
+
fields: list.map((column, index) => ({
|
|
240
|
+
key: column.field,
|
|
241
|
+
at: index + 2,
|
|
242
|
+
decode: column.decode
|
|
243
|
+
})),
|
|
244
|
+
includes: []
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
export {
|
|
248
|
+
planVersioned
|
|
249
|
+
};
|
|
@@ -135,8 +135,11 @@ class ColumnBuilder2 {
|
|
|
135
135
|
guarded() {
|
|
136
136
|
return rebuild(this.state, { guarded: true });
|
|
137
137
|
}
|
|
138
|
-
hidden() {
|
|
139
|
-
return rebuild(this.state, {
|
|
138
|
+
hidden(options) {
|
|
139
|
+
return rebuild(this.state, {
|
|
140
|
+
hidden: true,
|
|
141
|
+
...options?.filterable === true ? { filterable: true } : {}
|
|
142
|
+
});
|
|
140
143
|
}
|
|
141
144
|
sensitive() {
|
|
142
145
|
return rebuild(this.state, { sensitive: true });
|