okmodel 0.7.0 → 0.9.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 +14 -0
- package/dist/adapters/capabilities.d.ts +32 -0
- package/dist/adapters/failure.d.ts +1 -1
- package/dist/adapters/pg/bun-sql.d.ts +53 -0
- package/dist/adapters/pg/bunsql-extra.d.ts +1 -1
- package/dist/adapters/pg/bunsql.d.ts +1 -1
- 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 +1 -1
- package/dist/contracts/error.d.ts +1 -1
- package/dist/dialects/pg/ext/btree-gin.d.ts +26 -0
- package/dist/dialects/pg/ext/btree-gin.js +20 -0
- package/dist/dialects/pg/ext/btree-gist.d.ts +26 -0
- package/dist/dialects/pg/ext/btree-gist.js +20 -0
- package/dist/dialects/pg/ext/call.d.ts +53 -0
- package/dist/dialects/pg/ext/citext.js +1 -1
- package/dist/dialects/pg/ext/feature.d.ts +26 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.d.ts +34 -0
- package/dist/dialects/pg/ext/fuzzystrmatch.js +33 -0
- package/dist/dialects/pg/ext/hstore.d.ts +41 -0
- package/dist/dialects/pg/ext/hstore.js +29 -0
- package/dist/dialects/pg/ext/index.d.ts +56 -0
- package/dist/dialects/pg/ext/index.js +1 -1
- package/dist/dialects/pg/ext/ltree.d.ts +41 -0
- package/dist/dialects/pg/ext/ltree.js +29 -0
- package/dist/dialects/pg/ext/pg-trgm.js +4 -13
- package/dist/dialects/pg/ext/pgcrypto.d.ts +33 -0
- package/dist/dialects/pg/ext/pgcrypto.js +33 -0
- package/dist/dialects/pg/ext/unaccent.d.ts +26 -0
- package/dist/dialects/pg/ext/unaccent.js +21 -0
- package/dist/dialects/pg/ext/using.d.ts +23 -0
- package/dist/dialects/pg/ext/versions.d.ts +36 -0
- package/dist/dialects/pg/external.d.ts +19 -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 +3 -0
- package/dist/dialects/pg/index.js +394 -14
- package/dist/dialects/pg/introspect.d.ts +11 -0
- package/dist/dialects/pg/operators.d.ts +1 -1
- package/dist/dialects/pg/ops/fragment.d.ts +119 -0
- package/dist/dialects/pg/ops/lane.d.ts +49 -0
- 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 +11 -5
- package/dist/runtime/artifact-file.d.ts +22 -0
- package/dist/runtime/client.d.ts +10 -0
- package/dist/runtime/drift-detail.d.ts +2 -1
- package/dist/runtime/drift.d.ts +3 -10
- package/dist/runtime/otel.d.ts +105 -0
- package/dist/runtime/otel.js +97 -0
- package/dist/runtime/pg/bun.js +4 -4
- package/dist/runtime/pg/neon.d.ts +38 -0
- package/dist/runtime/pg/neon.js +64 -0
- package/dist/runtime/pg/pg.js +4 -4
- package/dist/runtime/pg/pglite.js +4 -4
- package/dist/runtime/pg/postgresjs.js +4 -4
- package/dist/runtime/plan.d.ts +1 -1
- package/dist/runtime/server-check.d.ts +36 -6
- package/dist/runtime/sql-fragment.d.ts +43 -0
- package/dist/runtime/tenancy/index.js +10 -10
- package/dist/runtime/topology.d.ts +1 -1
- package/dist/runtime/traits/index.js +16 -17
- package/dist/runtime/types.d.ts +15 -1
- package/dist/runtime/validate/index.js +4 -4
- package/dist/shared/{81ebdx9p.js → 0j6qe91y.js} +4 -4
- package/dist/shared/{qq3899ht.js → 12z7aznj.js} +243 -14
- package/dist/shared/{gzaveazc.js → 1d9q9cv2.js} +29 -2
- package/dist/shared/{w79hsckn.js → 1mxm04fy.js} +5 -5
- package/dist/shared/{7k9grvf6.js → 2szgv6yj.js} +5 -5
- package/dist/shared/{gs74dbj5.js → 2zdxkt7b.js} +933 -111
- package/dist/shared/{m6p12kbr.js → 3456242y.js} +23 -23
- package/dist/shared/3bb7wsqt.js +99 -0
- package/dist/shared/{y6njgyda.js → 3t6kw83m.js} +2 -2
- package/dist/shared/{xhfsfkgk.js → 4vbf83xx.js} +9 -2
- package/dist/shared/{pt94kz7f.js → 5kyb3tqx.js} +1 -1
- package/dist/shared/61bmrmhr.js +35 -0
- package/dist/shared/{x933k9a3.js → 62b603gr.js} +10 -10
- package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
- package/dist/shared/{tsvww22q.js → 6nae0spm.js} +156 -95
- package/dist/shared/{mtaszv5a.js → 71n0jmhc.js} +102 -4
- package/dist/shared/{5e3tf63j.js → 760ppr76.js} +14 -6
- package/dist/shared/7ba5h6pb.js +17 -0
- package/dist/shared/{sfz1ksn6.js → 8jesqsrk.js} +2 -2
- package/dist/shared/{5v3xf80k.js → 8n688yjg.js} +1 -1
- package/dist/shared/{rs73fca9.js → 8qzkd9f3.js} +6 -6
- package/dist/shared/{ax7qv55k.js → 90sg0w5a.js} +202 -25
- package/dist/shared/{zm0ptry0.js → 99qp9vtg.js} +1 -1
- package/dist/shared/{xnxsed62.js → 9dr2qnx7.js} +14 -14
- package/dist/shared/{1w508jbr.js → 9dtgn1z2.js} +21 -17
- package/dist/shared/{h15jx9bc.js → 9dvh1dr6.js} +1 -1
- package/dist/shared/{q5c6ngn3.js → a62rb2da.js} +1 -1
- package/dist/shared/{te5as7z7.js → aksb89mn.js} +3 -3
- package/dist/shared/{bz84tkzm.js → bphrgwz9.js} +2 -2
- package/dist/shared/bsek72fg.js +225 -0
- package/dist/shared/{7mnme5tn.js → c3mvnq7a.js} +1 -1
- package/dist/shared/{p6qc5gcp.js → ccsmhv9r.js} +25 -7
- package/dist/shared/{pbp1ss85.js → cexb7z6b.js} +2 -2
- package/dist/shared/{ab9gmbwy.js → cf8zdz5p.js} +5 -5
- package/dist/shared/{jvd0mqag.js → ckz05z15.js} +5 -5
- package/dist/shared/{dk8v79p3.js → d5nmj7vv.js} +1 -1
- package/dist/shared/{14vx95q4.js → dd5pmnky.js} +7 -7
- package/dist/shared/{vb6qfyve.js → ds229x4r.js} +2 -2
- package/dist/shared/{1qa0qajz.js → e275q7sd.js} +1 -1
- package/dist/shared/{zp9fmend.js → ebhz8vh6.js} +4 -4
- package/dist/shared/{hyh73qk6.js → ecn8mfdq.js} +5 -5
- package/dist/shared/{je4axnm8.js → fdsz3w80.js} +2 -2
- package/dist/shared/{9s0ypp87.js → fk9vef30.js} +85 -74
- package/dist/shared/{g6evj1j3.js → g89fmz5s.js} +1 -1
- package/dist/shared/{aytqh5y2.js → ghqzdp94.js} +2 -2
- package/dist/shared/h9811jjm.js +17 -0
- package/dist/shared/{dkxgzaqd.js → hqpxf4a4.js} +1 -1
- package/dist/shared/{8skf0cam.js → jpybhf98.js} +1 -1
- package/dist/shared/{67txcrcw.js → kgwp4jdd.js} +4 -4
- package/dist/shared/kzgrnckd.js +29 -0
- package/dist/shared/mazpbcdj.js +233 -0
- package/dist/shared/{kb2sdhfb.js → mfvx6kjx.js} +17 -1
- package/dist/shared/{svncdeh5.js → mgaq2sd3.js} +11 -8
- package/dist/shared/{5mtf6cj3.js → mvmm3xpb.js} +5 -2
- package/dist/shared/{b5pftnn2.js → myk8fswx.js} +66 -21
- package/dist/shared/{2shdbn8q.js → n306gqkd.js} +9 -9
- package/dist/shared/{n816peh1.js → n454kcnw.js} +1 -1
- package/dist/shared/n5whk3mt.js +665 -0
- package/dist/shared/n7kg8mmx.js +61 -0
- package/dist/shared/{vqrjpcqn.js → nmnsgj7x.js} +1 -1
- package/dist/shared/{tbrvgw6z.js → npdftanb.js} +19 -26
- package/dist/shared/{ek2wt2dz.js → pg4ezgyf.js} +11 -30
- package/dist/shared/{5fe3kbsh.js → pgsak1yw.js} +1 -1
- package/dist/shared/{bm22fvzr.js → qfw14tna.js} +2 -2
- package/dist/shared/{wa07eas9.js → qvwwp1mp.js} +62 -41
- package/dist/shared/rbxt795q.js +1766 -0
- package/dist/shared/{xjk7hnn5.js → s7he5e5d.js} +2 -2
- package/dist/shared/{w72kgg4q.js → ss2kv2rs.js} +6 -6
- package/dist/shared/stfa9xcw.js +450 -0
- package/dist/shared/{3v7t1yrv.js → th3be82n.js} +2 -2
- package/dist/shared/{79dt02vc.js → tr64w5p0.js} +1 -1
- package/dist/shared/{cn957f8d.js → tw1nvvfj.js} +3 -3
- package/dist/shared/{ed0b8k4s.js → typ3vy7t.js} +1 -1
- package/dist/shared/{9628a9xt.js → vk7rag46.js} +1 -1
- package/dist/shared/{ze4hxsmy.js → w9ejzaqf.js} +1 -1
- package/dist/shared/{vczs8gd4.js → wvtjg5m3.js} +2 -2
- package/dist/shared/{9y3mmmh1.js → xfhe73sb.js} +1 -1
- package/dist/shared/xqacq37x.js +61 -0
- package/dist/shared/{1est4ezg.js → xtsydxjg.js} +3 -3
- package/dist/shared/xv8qj97g.js +96 -0
- package/dist/shared/{bg3rym3g.js → xwhdcrm4.js} +2 -2
- package/dist/shared/{kr0jzbw2.js → yvabyg9k.js} +7 -7
- package/dist/shared/yybhre6n.js +136 -0
- package/dist/shared/zdqf8k5d.js +8 -0
- package/dist/shared/{jznfax0y.js → zq1he88x.js} +4 -4
- package/dist/tooling/cli.js +108 -23
- package/dist/tooling/driver-run.js +4654 -0
- package/dist/tooling/driver-test.d.ts +36 -0
- package/dist/tooling/github/comment.d.ts +50 -0
- package/dist/tooling/github/post-comment.d.ts +17 -0
- package/dist/tooling/migrate/commands.d.ts +3 -2
- package/dist/tooling/migrate/config.d.ts +13 -0
- package/dist/tooling/migrate/export.d.ts +165 -0
- package/dist/tooling/migrate/ext-surface.d.ts +80 -0
- package/dist/tooling/migrate/ext.d.ts +31 -4
- package/dist/tooling/migrate/import-drizzle.d.ts +40 -0
- package/dist/tooling/migrate/index.d.ts +3 -0
- package/dist/tooling/migrate/index.js +55 -10
- package/dist/tooling/migrate/lint-rules.d.ts +18 -1
- package/dist/tooling/migrate/lint.d.ts +14 -1
- package/dist/tooling/migrate/place.d.ts +18 -0
- package/dist/tooling/migrate/plan-json.d.ts +65 -0
- package/dist/tooling/migrate/project.d.ts +13 -1
- package/dist/tooling/migrate/pull-emit.d.ts +98 -0
- package/dist/tooling/migrate/pull-routines.d.ts +126 -0
- package/dist/tooling/migrate/pull-verify.d.ts +26 -0
- package/dist/tooling/migrate/pull.d.ts +62 -0
- package/dist/tooling/migrate/reprint.d.ts +32 -0
- package/dist/tooling/migrate/sandbox.d.ts +8 -2
- package/dist/tooling/migrate/schema-api.d.ts +43 -0
- package/dist/tooling/migrate/sql-lex.d.ts +18 -0
- package/dist/tooling/shared/04svnxxj.js +344 -0
- package/dist/tooling/shared/0j0jtse1.js +13 -0
- package/dist/tooling/shared/0r05zhyq.js +618 -0
- package/dist/tooling/shared/1800eymw.js +49 -0
- package/dist/tooling/shared/35zemrmf.js +12 -0
- package/dist/tooling/shared/3rmaz3pq.js +140 -0
- package/dist/tooling/shared/3yn79q5m.js +12 -0
- package/dist/tooling/shared/54tqkxja.js +51 -0
- package/dist/tooling/shared/57btdkgm.js +209 -0
- package/dist/tooling/shared/5bmksndh.js +118 -0
- package/dist/tooling/shared/5p8km5jb.js +38 -0
- package/dist/tooling/shared/5x3pf400.js +185 -0
- package/dist/tooling/shared/5zrzffnk.js +6 -0
- package/dist/tooling/shared/62fxpc1p.js +332 -0
- package/dist/tooling/shared/68tf18v4.js +20 -0
- package/dist/tooling/shared/6vk28rjp.js +98 -0
- package/dist/tooling/shared/76pv6qff.js +9 -0
- package/dist/tooling/shared/7aews1zg.js +311 -0
- package/dist/tooling/shared/7b3xp9gc.js +195 -0
- package/dist/tooling/shared/7kms6fvj.js +20 -0
- package/dist/tooling/shared/7pxncnzs.js +40 -0
- package/dist/tooling/shared/829fjxyw.js +198 -0
- package/dist/tooling/shared/8m5znpdt.js +66 -0
- package/dist/tooling/shared/8yr7ges1.js +211 -0
- package/dist/tooling/shared/96ps4g1z.js +32 -0
- package/dist/tooling/shared/9qr9rkbh.js +143 -0
- package/dist/tooling/shared/9sfbtwsk.js +49 -0
- package/dist/tooling/shared/9wsnsvbf.js +10 -0
- package/dist/tooling/shared/a2xe04bm.js +18 -0
- package/dist/tooling/shared/a4pzghha.js +20 -0
- package/dist/tooling/shared/am04v8na.js +233 -0
- package/dist/tooling/shared/asgr07mp.js +194 -0
- package/dist/tooling/shared/c0xevn1h.js +312 -0
- package/dist/tooling/shared/dhatassp.js +134 -0
- package/dist/tooling/shared/ezqn88nj.js +1696 -0
- package/dist/tooling/shared/f77nnfqy.js +231 -0
- package/dist/tooling/shared/fh07z1dt.js +15 -0
- package/dist/tooling/shared/gqwevek4.js +81 -0
- package/dist/tooling/shared/hfq3n3bd.js +4116 -0
- package/dist/tooling/shared/htnaj77v.js +17 -0
- package/dist/tooling/shared/j664qjrt.js +64 -0
- package/dist/tooling/shared/jpgmjsx3.js +38 -0
- package/dist/tooling/shared/jr2nmr81.js +497 -0
- package/dist/tooling/shared/jsjjz875.js +139 -0
- package/dist/tooling/shared/kbqnrs1x.js +1425 -0
- package/dist/tooling/shared/kz715295.js +94 -0
- package/dist/tooling/shared/m3xt8b1h.js +22 -0
- package/dist/tooling/shared/m4hhb8aa.js +9 -0
- package/dist/tooling/shared/mw5npye0.js +16 -0
- package/dist/tooling/shared/n4jqhpqz.js +27 -0
- package/dist/tooling/shared/nxq95eb6.js +42 -0
- package/dist/tooling/shared/qartgazh.js +70 -0
- package/dist/tooling/shared/rcywj2w8.js +190 -0
- package/dist/tooling/shared/s6qha57m.js +16 -0
- package/dist/tooling/shared/shjs0379.js +150 -0
- package/dist/tooling/shared/sjwkt1pg.js +16 -0
- package/dist/tooling/shared/stebqyyd.js +401 -0
- package/dist/tooling/shared/t4xveemq.js +250 -0
- package/dist/tooling/shared/t6zjeake.js +261 -0
- package/dist/tooling/shared/tcwpjvxe.js +9 -0
- package/dist/tooling/shared/tpssp7ac.js +160 -0
- package/dist/tooling/shared/v6j1ep6w.js +42 -0
- package/dist/tooling/shared/vwr2y833.js +270 -0
- package/dist/tooling/shared/w17sj05d.js +7 -0
- package/dist/tooling/shared/w5d89rb4.js +131 -0
- package/dist/tooling/shared/wbwq1jsa.js +157 -0
- package/dist/tooling/shared/wezxf3h8.js +17 -0
- package/dist/tooling/shared/yb4kd19s.js +12 -0
- package/dist/tooling/shared/ybdew6j7.js +294 -0
- package/dist/tooling/shared/yfedr1zb.js +6 -0
- package/dist/tooling/shared/yhp829bx.js +177 -0
- package/dist/tooling/shared/ytk1tjs0.js +604 -0
- package/dist/tooling/shared/zs9aymcp.js +210 -0
- package/dist/tooling/shared/zx3v9phv.js +8 -0
- package/dist/tooling/testing/index.js +3 -3
- package/package.json +50 -9
- package/dist/shared/ktz42yez.js +0 -113
- package/dist/shared/ttsqgp4p.js +0 -71
- package/dist/shared/y34a8714.js +0 -150
- 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
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
serializeCatalog2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./12z7aznj.js";
|
|
4
|
+
import {
|
|
5
|
+
quoteIdent2,
|
|
6
|
+
qualify2
|
|
7
|
+
} from "./fk9vef30.js";
|
|
4
8
|
import {
|
|
5
9
|
roleExists
|
|
6
|
-
} from "./
|
|
10
|
+
} from "./jpybhf98.js";
|
|
7
11
|
import {
|
|
8
12
|
canonicalTypeName,
|
|
9
13
|
createdRoleName,
|
|
@@ -16,24 +20,20 @@ import {
|
|
|
16
20
|
planMigration,
|
|
17
21
|
sessionFailure,
|
|
18
22
|
assertTargetPolicy
|
|
19
|
-
} from "./
|
|
20
|
-
import {
|
|
21
|
-
quoteIdent,
|
|
22
|
-
qualify
|
|
23
|
-
} from "./9s0ypp87.js";
|
|
23
|
+
} from "./6nae0spm.js";
|
|
24
24
|
import {
|
|
25
|
-
|
|
26
|
-
} from "./
|
|
25
|
+
snakeCase
|
|
26
|
+
} from "./gcefca6p.js";
|
|
27
27
|
import {
|
|
28
28
|
catalog,
|
|
29
29
|
isDomain
|
|
30
30
|
} from "./ywspezzx.js";
|
|
31
|
-
import {
|
|
32
|
-
snakeCase
|
|
33
|
-
} from "./rpycarcr.js";
|
|
34
31
|
import {
|
|
35
32
|
quoteLiteral
|
|
36
33
|
} from "./94ez8kzh.js";
|
|
34
|
+
import {
|
|
35
|
+
alignExtensionVersions
|
|
36
|
+
} from "./r3j8s5y0.js";
|
|
37
37
|
import {
|
|
38
38
|
identityKey2,
|
|
39
39
|
identityLabel2
|
|
@@ -70,7 +70,7 @@ async function runTarget(connection, run, session) {
|
|
|
70
70
|
async function assumeRole(connection, role, session) {
|
|
71
71
|
if (session.setRole === role)
|
|
72
72
|
return;
|
|
73
|
-
await connection.execute(`set role ${
|
|
73
|
+
await connection.execute(`set role ${quoteIdent2(role)}`);
|
|
74
74
|
session.setRole = role;
|
|
75
75
|
}
|
|
76
76
|
async function grantAppMeta(connection, role, session) {
|
|
@@ -79,12 +79,12 @@ async function grantAppMeta(connection, role, session) {
|
|
|
79
79
|
const previous = session.setRole;
|
|
80
80
|
if (previous !== undefined)
|
|
81
81
|
await connection.execute("reset role");
|
|
82
|
-
await connection.execute(`grant select on okm_meta to ${
|
|
82
|
+
await connection.execute(`grant select on okm_meta to ${quoteIdent2(role)}`);
|
|
83
83
|
if (previous !== undefined)
|
|
84
|
-
await connection.execute(`set role ${
|
|
84
|
+
await connection.execute(`set role ${quoteIdent2(previous)}`);
|
|
85
85
|
}
|
|
86
86
|
async function grantSchema(connection, schema, role) {
|
|
87
|
-
await connection.execute(`grant usage, create on schema ${
|
|
87
|
+
await connection.execute(`grant usage, create on schema ${quoteIdent2(schema)} to ${quoteIdent2(role)}`);
|
|
88
88
|
}
|
|
89
89
|
async function runUnit(connection, unit, run, session) {
|
|
90
90
|
const only = unit.steps.length === 1 ? unit.steps[0] : undefined;
|
|
@@ -113,7 +113,7 @@ async function runUnit(connection, unit, run, session) {
|
|
|
113
113
|
if (created !== undefined && created === run.migrationRole) {
|
|
114
114
|
if (!existed) {
|
|
115
115
|
await grantSchema(connection, run.schema ?? "public", created);
|
|
116
|
-
await connection.execute(`grant select, insert, update on okm_meta, okm_history, okm_backfill to ${
|
|
116
|
+
await connection.execute(`grant select, insert, update on okm_meta, okm_history, okm_backfill to ${quoteIdent2(created)}`);
|
|
117
117
|
}
|
|
118
118
|
await assumeRole(connection, created, session);
|
|
119
119
|
}
|
|
@@ -305,7 +305,7 @@ async function rebuildInvalidIndex(connection, sql) {
|
|
|
305
305
|
const valid = found.rows[0]?.[0];
|
|
306
306
|
if (valid === undefined || wireTrue(valid))
|
|
307
307
|
return;
|
|
308
|
-
await connection.execute(`drop index concurrently if exists ${
|
|
308
|
+
await connection.execute(`drop index concurrently if exists ${quoteIdent2(name)}`);
|
|
309
309
|
}
|
|
310
310
|
function concurrentIndexName(sql) {
|
|
311
311
|
const match = /^create\s+(?:unique\s+)?index\s+concurrently\s+(?:if\s+not\s+exists\s+)?(?:"([^"]+)"|([A-Za-z_][\w$]*))/i.exec(sql.trim());
|
|
@@ -331,7 +331,7 @@ async function assertSchemaUsageLanded(connection, sql) {
|
|
|
331
331
|
throw new OkmError2("OKM1825", `Grant usage on schema ${schema} to ${role} did not take effect.`, {
|
|
332
332
|
kind: "forbidden",
|
|
333
333
|
fix: {
|
|
334
|
-
summary: `Make the migration role the owner of schema ${schema}. ALTER SCHEMA ${
|
|
334
|
+
summary: `Make the migration role the owner of schema ${schema}. ALTER SCHEMA ${quoteIdent2(schema)} OWNER TO <migration role>.`
|
|
335
335
|
}
|
|
336
336
|
});
|
|
337
337
|
}
|
|
@@ -423,11 +423,11 @@ function readReference(tables, casing, head) {
|
|
|
423
423
|
function referenceInserts(tables, schema) {
|
|
424
424
|
const statements = [];
|
|
425
425
|
for (const item of tables) {
|
|
426
|
-
const conflict = item.key.map((name) =>
|
|
426
|
+
const conflict = item.key.map((name) => quoteIdent2(name)).join(", ");
|
|
427
427
|
for (const row of item.rows) {
|
|
428
|
-
const columns = row.map(([name]) =>
|
|
428
|
+
const columns = row.map(([name]) => quoteIdent2(name)).join(", ");
|
|
429
429
|
const values = row.map(([, value]) => literal(value)).join(", ");
|
|
430
|
-
statements.push(`insert into ${
|
|
430
|
+
statements.push(`insert into ${qualify2(schema, item.table)} (${columns}) values (${values}) on conflict (${conflict}) do nothing`);
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
return statements;
|
|
@@ -616,7 +616,7 @@ async function installSnapshot(connection, head, schema, reference, session, mig
|
|
|
616
616
|
if (created !== undefined && created === migrationRole) {
|
|
617
617
|
await flush();
|
|
618
618
|
await grantSchema(connection, schema, created);
|
|
619
|
-
await connection.execute(`grant select, insert, update on okm_meta, okm_history, okm_backfill to ${
|
|
619
|
+
await connection.execute(`grant select, insert, update on okm_meta, okm_history, okm_backfill to ${quoteIdent2(created)}`);
|
|
620
620
|
await assumeRole(connection, created, session);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isFragmentParts
|
|
3
|
+
} from "./bsek72fg.js";
|
|
4
|
+
import {
|
|
5
|
+
refuseHidden,
|
|
6
|
+
quote,
|
|
7
|
+
list,
|
|
8
|
+
fail2
|
|
9
|
+
} from "./kgwp4jdd.js";
|
|
10
|
+
import {
|
|
11
|
+
OkmError2,
|
|
12
|
+
throwNamed2
|
|
13
|
+
} from "./52szzakm.js";
|
|
14
|
+
|
|
15
|
+
// src/runtime/sql-fragment.ts
|
|
16
|
+
function emitSqlValue(table, ref, value, sink) {
|
|
17
|
+
const dot = ref.indexOf(".");
|
|
18
|
+
const alias = dot < 0 ? ref : ref.slice(0, dot);
|
|
19
|
+
writeFragment(requireParts(value), sink, alias, ref, table, "where");
|
|
20
|
+
}
|
|
21
|
+
function emitSqlSelect(table, parts, sink, alias) {
|
|
22
|
+
writeFragment(parts, sink, alias, undefined, table, "select");
|
|
23
|
+
}
|
|
24
|
+
function decodeSqlNumber(wire) {
|
|
25
|
+
const parsed = Number(wire);
|
|
26
|
+
if (!Number.isFinite(parsed)) {
|
|
27
|
+
throw new OkmError2("OKM1125", "A select fragment must be a number.", {
|
|
28
|
+
fix: { summary: "Use a numeric expression, such as length(title). Text stays in where." }
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return parsed;
|
|
32
|
+
}
|
|
33
|
+
function requireParts(value) {
|
|
34
|
+
if (!isFragmentParts(value)) {
|
|
35
|
+
throw new OkmError2("OKM1125", "A fragment was not created by fragment``.", {
|
|
36
|
+
fix: { summary: "Call fragment`...`." }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
function writeFragment(parts, sink, alias, ref, table, place) {
|
|
42
|
+
sink.mark(":g");
|
|
43
|
+
sink.text("(");
|
|
44
|
+
for (const part of parts)
|
|
45
|
+
writePart(part, sink, alias, ref, table, place);
|
|
46
|
+
sink.mark(":g");
|
|
47
|
+
sink.text(")");
|
|
48
|
+
}
|
|
49
|
+
function writePart(part, sink, alias, ref, table, place) {
|
|
50
|
+
if (part.k === "t") {
|
|
51
|
+
sink.mark(`:t:${String(part.s.length)}:${part.s}`);
|
|
52
|
+
sink.text(part.s);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (part.k === "p") {
|
|
56
|
+
sink.mark(":p");
|
|
57
|
+
sink.param(part.v);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (part.k === "n") {
|
|
61
|
+
sink.mark(":n");
|
|
62
|
+
sink.text("null");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (part.k === "i") {
|
|
66
|
+
writeIdent(part.n, table, sink, alias, place);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (part.k === "c") {
|
|
70
|
+
if (ref === undefined) {
|
|
71
|
+
throw new OkmError2("OKM1125", "fragment.column belongs on a where field.", {
|
|
72
|
+
fix: { summary: "Use ident(name) in select, or put fragment.column on a where field." }
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
sink.mark(":c");
|
|
76
|
+
sink.text(ref);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
writeFragment(part.parts, sink, alias, ref, table, place);
|
|
80
|
+
}
|
|
81
|
+
function writeIdent(name, table, sink, alias, place) {
|
|
82
|
+
const column = table.columns.get(name);
|
|
83
|
+
if (column === undefined) {
|
|
84
|
+
throwNamed2("OKM1120", name, table.names, `Field ${name} is not on ${table.model.name}. Accepted names: ${list(table.names)}.`);
|
|
85
|
+
}
|
|
86
|
+
if (place === "select") {
|
|
87
|
+
if (column.hidden) {
|
|
88
|
+
fail2("OKM1120", `Field ${column.field} is hidden.`, "A select fragment cannot name a hidden field.");
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
refuseHidden(column);
|
|
92
|
+
}
|
|
93
|
+
sink.mark(`:i:${String(column.field.length)}:${column.field}`);
|
|
94
|
+
sink.text(alias);
|
|
95
|
+
sink.text(".");
|
|
96
|
+
sink.text(quote(column.sql));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { emitSqlValue, emitSqlSelect, decodeSqlNumber };
|
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
expectOf2,
|
|
16
16
|
allowSet2,
|
|
17
17
|
noteGuarded2
|
|
18
|
-
} from "./
|
|
18
|
+
} from "./9dtgn1z2.js";
|
|
19
19
|
import {
|
|
20
20
|
emitWhere,
|
|
21
21
|
projectExpr,
|
|
22
22
|
quote,
|
|
23
23
|
isRecord,
|
|
24
24
|
fail2
|
|
25
|
-
} from "./
|
|
25
|
+
} from "./kgwp4jdd.js";
|
|
26
26
|
|
|
27
27
|
// src/runtime/version.ts
|
|
28
28
|
function planVersioned(schema, table, input, options, mods) {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
emitSqlValue
|
|
3
|
+
} from "./3bb7wsqt.js";
|
|
1
4
|
import {
|
|
2
5
|
assertOperatorFits,
|
|
3
6
|
sqlType,
|
|
@@ -11,7 +14,7 @@ import {
|
|
|
11
14
|
quote,
|
|
12
15
|
isRecord,
|
|
13
16
|
fail2
|
|
14
|
-
} from "./
|
|
17
|
+
} from "./kgwp4jdd.js";
|
|
15
18
|
import {
|
|
16
19
|
isOperator,
|
|
17
20
|
operatorName,
|
|
@@ -19,7 +22,11 @@ import {
|
|
|
19
22
|
} from "./cn0n68ft.js";
|
|
20
23
|
|
|
21
24
|
// src/runtime/operator-sql.ts
|
|
22
|
-
function emitStructured(column, ref, name, value, sink, order) {
|
|
25
|
+
function emitStructured(table, column, ref, name, value, sink, order) {
|
|
26
|
+
if (name === "sql") {
|
|
27
|
+
emitSqlValue(table, ref, value, sink);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
23
30
|
if (name === "contains" || name === "containedBy" || name === "overlaps") {
|
|
24
31
|
emitContainment(column, ref, name, value, sink);
|
|
25
32
|
return;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
quoteIdent2,
|
|
3
|
+
renderCatalog2,
|
|
4
|
+
uniqueBeforeForeignKey2,
|
|
5
|
+
ownedByView2,
|
|
6
|
+
dropObjectSql2,
|
|
7
|
+
createObjectSql2,
|
|
8
|
+
functionSql2,
|
|
9
|
+
viewSql2,
|
|
10
|
+
policyCreatePlan2,
|
|
11
|
+
policyDropPlan2,
|
|
12
|
+
refreshMaterializedViewSql2,
|
|
13
|
+
alterColumnSql2,
|
|
14
|
+
identitySequence2,
|
|
15
|
+
createTableSql2,
|
|
16
|
+
qualify2
|
|
17
|
+
} from "./fk9vef30.js";
|
|
18
|
+
import"./12z7aznj.js";
|
|
19
|
+
export {
|
|
20
|
+
alterColumnSql2 as alterColumnSql,
|
|
21
|
+
createObjectSql2 as createObjectSql,
|
|
22
|
+
createTableSql2 as createTableSql,
|
|
23
|
+
dropObjectSql2 as dropObjectSql,
|
|
24
|
+
functionSql2 as functionSql,
|
|
25
|
+
identitySequence2 as identitySequence,
|
|
26
|
+
ownedByView2 as ownedByView,
|
|
27
|
+
policyCreatePlan2 as policyCreatePlan,
|
|
28
|
+
policyDropPlan2 as policyDropPlan,
|
|
29
|
+
qualify2 as qualify,
|
|
30
|
+
quoteIdent2 as quoteIdent,
|
|
31
|
+
refreshMaterializedViewSql2 as refreshMaterializedViewSql,
|
|
32
|
+
renderCatalog2 as renderCatalog,
|
|
33
|
+
uniqueBeforeForeignKey2 as uniqueBeforeForeignKey,
|
|
34
|
+
viewSql2 as viewSql
|
|
35
|
+
};
|
|
@@ -3,21 +3,21 @@ import {
|
|
|
3
3
|
} from "./cm3w0ywp.js";
|
|
4
4
|
import {
|
|
5
5
|
noTimeout
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./tr64w5p0.js";
|
|
7
7
|
import {
|
|
8
8
|
noticeBuffer,
|
|
9
9
|
WireSession
|
|
10
|
-
} from "./
|
|
10
|
+
} from "./e275q7sd.js";
|
|
11
11
|
import {
|
|
12
12
|
BUNSQL_CAPABILITIES,
|
|
13
13
|
driverErrors,
|
|
14
14
|
rejectClosed,
|
|
15
15
|
mapFailure,
|
|
16
16
|
runCall
|
|
17
|
-
} from "./
|
|
17
|
+
} from "./mfvx6kjx.js";
|
|
18
18
|
|
|
19
19
|
// src/adapters/pg/bunsql.ts
|
|
20
|
-
import { SQL } from "bun";
|
|
20
|
+
import { SQL as BunSQL } from "bun";
|
|
21
21
|
var clientPools = new WeakSet;
|
|
22
22
|
function markClientPool(pool) {
|
|
23
23
|
clientPools.add(pool);
|
|
@@ -33,7 +33,7 @@ function open5(config) {
|
|
|
33
33
|
const parked = [];
|
|
34
34
|
let dropped = 0;
|
|
35
35
|
let closures = 0;
|
|
36
|
-
const sql = new
|
|
36
|
+
const sql = new BunSQL(config.url, {
|
|
37
37
|
max,
|
|
38
38
|
idleTimeout: 0,
|
|
39
39
|
maxLifetime: 0,
|
|
@@ -66,19 +66,19 @@ function open5(config) {
|
|
|
66
66
|
};
|
|
67
67
|
const run = (text, params, watch) => {
|
|
68
68
|
const sent = dropped;
|
|
69
|
-
return root.query(text, params, watch).catch((error) => import("./
|
|
69
|
+
return root.query(text, params, watch).catch((error) => import("./cf8zdz5p.js").then((mod) => mod.recover(sql, error, text, root.depth(), clientPools.has(pool), dropped > sent, () => root.query(text, params, watch))));
|
|
70
70
|
};
|
|
71
71
|
const afterDrop = (text, params, watch) => {
|
|
72
72
|
if (dropped === 0)
|
|
73
73
|
return run(text, params, watch);
|
|
74
74
|
const seen = dropped;
|
|
75
|
-
return import("./
|
|
75
|
+
return import("./cf8zdz5p.js").then((mod) => mod.drainClosed(sql).then(() => {
|
|
76
76
|
if (dropped === seen)
|
|
77
77
|
dropped = 0;
|
|
78
78
|
return run(text, params, watch);
|
|
79
79
|
}));
|
|
80
80
|
};
|
|
81
|
-
const checkout = () => closed ? rejectClosed() : import("./
|
|
81
|
+
const checkout = () => closed ? rejectClosed() : import("./cf8zdz5p.js").then((mod) => mod.checkout(held));
|
|
82
82
|
const pool = {
|
|
83
83
|
capabilities: BUNSQL_CAPABILITIES,
|
|
84
84
|
execute(text, params, options) {
|
|
@@ -101,12 +101,12 @@ function open5(config) {
|
|
|
101
101
|
reserve: () => checkout(),
|
|
102
102
|
stream(text, params) {
|
|
103
103
|
return async function* () {
|
|
104
|
-
const { streamRows } = await import("./
|
|
104
|
+
const { streamRows } = await import("./cf8zdz5p.js");
|
|
105
105
|
yield* streamRows(checkout, text, params);
|
|
106
106
|
}();
|
|
107
107
|
},
|
|
108
108
|
listen(channel, onNotify) {
|
|
109
|
-
return import("./
|
|
109
|
+
return import("./cf8zdz5p.js").then((mod) => mod.listen(sql, parked, closed, channel, onNotify));
|
|
110
110
|
},
|
|
111
111
|
stats: () => statsOf(counters, max),
|
|
112
112
|
async close() {
|
|
@@ -10,6 +10,8 @@ function extension2(name, options = {}) {
|
|
|
10
10
|
const schema = options.schema ?? "public";
|
|
11
11
|
const relocatable = options.relocatable ?? true;
|
|
12
12
|
const version = options.version;
|
|
13
|
+
const requires = options.requires;
|
|
14
|
+
const provides = options.provides;
|
|
13
15
|
const record = extensionObject({
|
|
14
16
|
name,
|
|
15
17
|
schema,
|
|
@@ -22,6 +24,8 @@ function extension2(name, options = {}) {
|
|
|
22
24
|
schema,
|
|
23
25
|
relocatable,
|
|
24
26
|
...version !== undefined ? { version } : {},
|
|
27
|
+
...requires !== undefined ? { requires } : {},
|
|
28
|
+
...provides !== undefined ? { provides } : {},
|
|
25
29
|
contribute(peers, built) {
|
|
26
30
|
const names = peerNames(peers);
|
|
27
31
|
assertDeclared(names, built);
|