okmodel 0.8.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/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.js +4 -4
- package/dist/dialects/pg/index.d.ts +1 -0
- package/dist/dialects/pg/index.js +16 -11
- package/dist/dialects/pg/view/index.js +5 -5
- package/dist/dialects/pg/view/scratch.d.ts +4 -1
- 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/pg/bun.js +4 -4
- package/dist/runtime/pg/neon.js +4 -4
- 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/server-check.d.ts +36 -6
- package/dist/runtime/traits/index.js +5 -5
- package/dist/runtime/validate/index.js +1 -1
- package/dist/shared/{4m6hskg8.js → 0j6qe91y.js} +4 -4
- package/dist/shared/{14x60fbf.js → 1mxm04fy.js} +5 -5
- package/dist/shared/{b6d6p0zc.js → 2szgv6yj.js} +5 -5
- package/dist/shared/{f4jy1j7x.js → 2zdxkt7b.js} +909 -100
- package/dist/shared/{mnvjvqyp.js → 3456242y.js} +17 -17
- package/dist/shared/3t6kw83m.js +1 -1
- package/dist/shared/{6m78c8ss.js → 5kyb3tqx.js} +1 -1
- package/dist/shared/61bmrmhr.js +35 -0
- package/dist/shared/{zbqbmmrp.js → 62b603gr.js} +8 -8
- package/dist/shared/{jgqj11w4.js → 6f0z3hzh.js} +4 -0
- package/dist/shared/{dpc2r7rb.js → 6nae0spm.js} +150 -89
- package/dist/shared/{0wrea3jq.js → 71n0jmhc.js} +1 -1
- package/dist/shared/7ba5h6pb.js +17 -0
- package/dist/shared/{k86n8vq3.js → 8jesqsrk.js} +1 -1
- package/dist/shared/{qd9hhd8f.js → 8n688yjg.js} +1 -1
- package/dist/shared/{zgex00fd.js → 8qzkd9f3.js} +5 -5
- package/dist/shared/{mkrn359n.js → 90sg0w5a.js} +159 -31
- package/dist/shared/{7ghwamrf.js → 99qp9vtg.js} +1 -1
- package/dist/shared/{bxas03mq.js → 9dtgn1z2.js} +1 -1
- package/dist/shared/{p5nh3r8q.js → aksb89mn.js} +2 -2
- package/dist/shared/{wcrheftc.js → bphrgwz9.js} +2 -2
- package/dist/shared/{wz2a78mp.js → c3mvnq7a.js} +1 -1
- package/dist/shared/{pan0370z.js → ccsmhv9r.js} +24 -6
- package/dist/shared/{n0jmpgj1.js → cexb7z6b.js} +1 -1
- package/dist/shared/{wvdjznah.js → cf8zdz5p.js} +5 -5
- package/dist/shared/{3449rcae.js → ckz05z15.js} +4 -4
- package/dist/shared/{35q0n9tz.js → dd5pmnky.js} +7 -7
- package/dist/shared/{e8zyaqvj.js → ds229x4r.js} +1 -1
- package/dist/{tooling/shared/yw30vnq2.js → shared/e275q7sd.js} +1 -1
- package/dist/shared/{mfedzr74.js → ebhz8vh6.js} +4 -4
- package/dist/shared/{z581d7ny.js → fdsz3w80.js} +2 -2
- package/dist/shared/{sjk86yrx.js → fk9vef30.js} +84 -73
- package/dist/shared/{needfe47.js → g89fmz5s.js} +1 -1
- package/dist/shared/{m4xff2a6.js → ghqzdp94.js} +2 -2
- package/dist/shared/h9811jjm.js +17 -0
- package/dist/shared/{kj9d8maq.js → jpybhf98.js} +1 -1
- package/dist/shared/kzgrnckd.js +29 -0
- package/dist/shared/{agsfb86s.js → mazpbcdj.js} +4 -4
- package/dist/shared/{195pzzzz.js → mgaq2sd3.js} +10 -7
- package/dist/shared/{5mtf6cj3.js → mvmm3xpb.js} +5 -2
- package/dist/shared/{p3xbdcvt.js → myk8fswx.js} +55 -6
- package/dist/shared/{njga14v4.js → n306gqkd.js} +8 -8
- package/dist/shared/n5whk3mt.js +665 -0
- package/dist/shared/{bah9nbg3.js → npdftanb.js} +12 -20
- package/dist/shared/{16kvjebh.js → pg4ezgyf.js} +7 -26
- package/dist/{tooling/shared/08kemxjd.js → shared/pgsak1yw.js} +1 -1
- package/dist/shared/{jp36k7dp.js → qvwwp1mp.js} +61 -40
- package/dist/shared/rbxt795q.js +1766 -0
- package/dist/shared/{g5yc06ka.js → s7he5e5d.js} +1 -1
- package/dist/shared/{hfqmpasr.js → ss2kv2rs.js} +5 -5
- package/dist/shared/stfa9xcw.js +450 -0
- package/dist/{tooling/shared/rs1jb051.js → shared/tr64w5p0.js} +1 -1
- package/dist/shared/{jebgrkeq.js → tw1nvvfj.js} +2 -2
- package/dist/shared/{v1wad97q.js → wvtjg5m3.js} +1 -1
- package/dist/shared/xqacq37x.js +61 -0
- package/dist/shared/{n05z9nwz.js → xtsydxjg.js} +1 -1
- package/dist/shared/{jx2m62cs.js → xv8qj97g.js} +5 -5
- package/dist/shared/{63f4ksbz.js → xwhdcrm4.js} +1 -1
- package/dist/shared/{hm5f8jby.js → yvabyg9k.js} +6 -6
- package/dist/shared/yybhre6n.js +136 -0
- package/dist/shared/zdqf8k5d.js +8 -0
- package/dist/tooling/cli.js +94 -22
- package/dist/tooling/driver-run.js +15 -332
- 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 +2 -1
- 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 +10 -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/{3m1hkg7z.js → 04svnxxj.js} +4 -4
- package/dist/tooling/shared/{ppnnnvj8.js → 0j0jtse1.js} +1 -1
- package/dist/tooling/shared/{z8d7ptht.js → 0r05zhyq.js} +5 -5
- package/dist/tooling/shared/{a6pp9d12.js → 1800eymw.js} +3 -3
- package/dist/tooling/shared/{cmptmb4f.js → 35zemrmf.js} +1 -1
- package/dist/tooling/shared/{w7qe8sj1.js → 3rmaz3pq.js} +1 -1
- package/dist/{shared/q0cqt2sp.js → tooling/shared/3yn79q5m.js} +1 -1
- package/dist/tooling/shared/{2revefqt.js → 57btdkgm.js} +2 -2
- package/dist/tooling/shared/{ma2340rx.js → 5bmksndh.js} +2 -2
- package/dist/tooling/shared/{9xzm7hjg.js → 5p8km5jb.js} +3 -3
- package/dist/tooling/shared/{xhrnjch9.js → 5x3pf400.js} +3 -3
- package/dist/tooling/shared/{wwnekq5n.js → 5zrzffnk.js} +1 -1
- package/dist/tooling/shared/{p7f08ktn.js → 62fxpc1p.js} +7 -7
- package/dist/tooling/shared/{7ae7rjmn.js → 68tf18v4.js} +2 -2
- package/dist/tooling/shared/{rf83gr2d.js → 6vk28rjp.js} +7 -3
- package/dist/tooling/shared/76pv6qff.js +9 -0
- package/dist/tooling/shared/{bz2dqhab.js → 7aews1zg.js} +3 -3
- package/dist/tooling/shared/{9kazs5p6.js → 7b3xp9gc.js} +3 -3
- package/dist/tooling/shared/{4d2w25vw.js → 7pxncnzs.js} +2 -2
- package/dist/tooling/shared/{zvnhh1n0.js → 829fjxyw.js} +2 -2
- package/dist/tooling/shared/{dzx85q70.js → 8m5znpdt.js} +1 -1
- package/dist/tooling/shared/{g9ad4n80.js → 8yr7ges1.js} +7 -7
- package/dist/tooling/shared/{tn8gay14.js → 9qr9rkbh.js} +6 -6
- package/dist/tooling/shared/{8sqrsw3s.js → 9sfbtwsk.js} +3 -3
- package/dist/{shared/bnby0esn.js → tooling/shared/9wsnsvbf.js} +1 -1
- package/dist/tooling/shared/{aftb2mwr.js → a2xe04bm.js} +1 -1
- package/dist/tooling/shared/{nf7jmhfa.js → a4pzghha.js} +2 -2
- package/dist/tooling/shared/{y5656f0e.js → am04v8na.js} +5 -5
- package/dist/tooling/shared/{417zdsk7.js → asgr07mp.js} +5 -5
- package/dist/tooling/shared/{pqy21k24.js → c0xevn1h.js} +4 -4
- package/dist/tooling/shared/dhatassp.js +134 -0
- package/dist/tooling/shared/{spk1jg3r.js → ezqn88nj.js} +8 -8
- package/dist/tooling/shared/{6nyfyw70.js → f77nnfqy.js} +2 -2
- package/dist/tooling/shared/{wt7j7nf6.js → fh07z1dt.js} +1 -1
- package/dist/tooling/shared/{3rrw5w8f.js → gqwevek4.js} +1 -1
- package/dist/tooling/shared/{f9mphxej.js → hfq3n3bd.js} +346 -19
- package/dist/tooling/shared/{vs0t6qt8.js → j664qjrt.js} +2 -2
- package/dist/tooling/shared/{733a1tq3.js → jpgmjsx3.js} +3 -3
- package/dist/tooling/shared/{mtrqn2hn.js → jr2nmr81.js} +22 -30
- package/dist/{shared/mtw6jz76.js → tooling/shared/jsjjz875.js} +1 -1
- package/dist/tooling/shared/{2wtvc7rw.js → kbqnrs1x.js} +2 -2
- package/dist/tooling/shared/{gfvtj6d0.js → kz715295.js} +7 -7
- package/dist/tooling/shared/{a7q7t4n3.js → m3xt8b1h.js} +2 -2
- package/dist/tooling/shared/{dw08f3m8.js → m4hhb8aa.js} +2 -2
- package/dist/tooling/shared/{y031jct9.js → mw5npye0.js} +2 -2
- package/dist/tooling/shared/{vraj6d74.js → nxq95eb6.js} +3 -3
- package/dist/tooling/shared/{fb9k2qwd.js → qartgazh.js} +11 -30
- package/dist/tooling/shared/{xjs6zqtc.js → rcywj2w8.js} +9 -9
- package/dist/tooling/shared/{dy672fz6.js → s6qha57m.js} +2 -2
- package/dist/tooling/shared/{vx86qjv8.js → shjs0379.js} +3 -3
- package/dist/tooling/shared/{345tbc2k.js → sjwkt1pg.js} +1 -1
- package/dist/tooling/shared/{rq5kk8j6.js → stebqyyd.js} +3 -3
- package/dist/tooling/shared/{yk9mp7vb.js → t4xveemq.js} +4 -4
- package/dist/tooling/shared/{djydjpqt.js → t6zjeake.js} +5 -5
- package/dist/tooling/shared/{zhwnfyb2.js → tcwpjvxe.js} +1 -1
- package/dist/tooling/shared/{72fyg4zv.js → tpssp7ac.js} +1 -1
- package/dist/tooling/shared/{jne7b93p.js → v6j1ep6w.js} +3 -3
- package/dist/tooling/shared/{ec71zqgt.js → vwr2y833.js} +2 -2
- package/dist/tooling/shared/{j9t5s12a.js → w17sj05d.js} +2 -2
- package/dist/tooling/shared/{3tq8pnb8.js → w5d89rb4.js} +1 -1
- package/dist/tooling/shared/{smn6kz1p.js → wbwq1jsa.js} +2 -2
- package/dist/tooling/shared/{pwsytxm5.js → wezxf3h8.js} +1 -1
- package/dist/tooling/shared/{5bvw2nev.js → yb4kd19s.js} +1 -1
- package/dist/tooling/shared/{gmcf9cxf.js → ybdew6j7.js} +2 -2
- package/dist/tooling/shared/{ep8zh3bk.js → yfedr1zb.js} +1 -1
- package/dist/tooling/shared/{ddjtfgnx.js → yhp829bx.js} +3 -3
- package/dist/tooling/shared/{yfr8hzhm.js → ytk1tjs0.js} +1 -1
- package/dist/tooling/shared/{03k6res6.js → zs9aymcp.js} +1 -1
- package/dist/tooling/shared/zx3v9phv.js +8 -0
- package/dist/tooling/testing/index.js +2 -2
- package/package.json +38 -9
- package/dist/shared/fjpnhqan.js +0 -71
- package/dist/shared/n41w4fbz.js +0 -113
- package/dist/tooling/shared/pw8fgahx.js +0 -69
- /package/dist/shared/{ae4j5f42.js → mfvx6kjx.js} +0 -0
|
@@ -2285,6 +2285,351 @@ function isPlainRecord(value) {
|
|
|
2285
2285
|
function assertNever2(value) {
|
|
2286
2286
|
return catalogError("OKM1020", `Unexpected catalog object ${JSON.stringify(value)}.`);
|
|
2287
2287
|
}
|
|
2288
|
+
// src/dialects/pg/quote.ts
|
|
2289
|
+
function quoteLiteral(value) {
|
|
2290
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
2291
|
+
}
|
|
2292
|
+
function arrayElement(encoded, raw) {
|
|
2293
|
+
if (raw && (encoded === "true" || encoded === "false" || isBareNumber(encoded))) {
|
|
2294
|
+
return encoded;
|
|
2295
|
+
}
|
|
2296
|
+
return `"${encoded.replaceAll("\\", "\\\\").replaceAll('"', "\\\"")}"`;
|
|
2297
|
+
}
|
|
2298
|
+
function isBareNumber(encoded) {
|
|
2299
|
+
let pattern = bareNumber;
|
|
2300
|
+
pattern ??= /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
2301
|
+
bareNumber = pattern;
|
|
2302
|
+
return pattern.test(encoded);
|
|
2303
|
+
}
|
|
2304
|
+
var bareNumber;
|
|
2305
|
+
|
|
2306
|
+
// src/dialects/pg/ddl.ts
|
|
2307
|
+
function quoteIdent2(name) {
|
|
2308
|
+
return `"${name.replaceAll('"', '""')}"`;
|
|
2309
|
+
}
|
|
2310
|
+
function renderCatalog2(source, schema) {
|
|
2311
|
+
const folded = foldedKeys(source);
|
|
2312
|
+
const statements = [];
|
|
2313
|
+
const ordered = creationOrder2(source);
|
|
2314
|
+
const created = uniqueBeforeForeignKey(ordered);
|
|
2315
|
+
for (const object of ordered) {
|
|
2316
|
+
if (object.kind !== "type" || object.owner === "ignored")
|
|
2317
|
+
continue;
|
|
2318
|
+
const sql = createObjectSql(object, schema);
|
|
2319
|
+
if (sql !== undefined)
|
|
2320
|
+
statements.push(sql);
|
|
2321
|
+
}
|
|
2322
|
+
for (const object of created) {
|
|
2323
|
+
if (object.kind === "type" || object.kind === "function" || object.kind === "trigger" || object.kind === "view" || object.kind === "materializedView" || object.kind === "policy" || ownedByView(object)) {
|
|
2324
|
+
continue;
|
|
2325
|
+
}
|
|
2326
|
+
if (object.owner === "ignored")
|
|
2327
|
+
continue;
|
|
2328
|
+
const key = identityKey(object.identity);
|
|
2329
|
+
if (object.kind === "table") {
|
|
2330
|
+
statements.push(createTableSql(object, source, schema));
|
|
2331
|
+
continue;
|
|
2332
|
+
}
|
|
2333
|
+
if (folded.has(key))
|
|
2334
|
+
continue;
|
|
2335
|
+
const sql = createObjectSql(object, schema);
|
|
2336
|
+
if (sql !== undefined)
|
|
2337
|
+
statements.push(sql);
|
|
2338
|
+
}
|
|
2339
|
+
for (const object of created) {
|
|
2340
|
+
if (object.kind !== "policy" || object.owner === "ignored")
|
|
2341
|
+
continue;
|
|
2342
|
+
for (const step of policyCreatePlan(object, schema))
|
|
2343
|
+
statements.push(step.sql);
|
|
2344
|
+
}
|
|
2345
|
+
for (const kind of ["function", "trigger"]) {
|
|
2346
|
+
for (const object of ordered) {
|
|
2347
|
+
if (object.kind !== kind || object.owner === "ignored")
|
|
2348
|
+
continue;
|
|
2349
|
+
const sql = createObjectSql(object, schema);
|
|
2350
|
+
if (sql !== undefined)
|
|
2351
|
+
statements.push(sql);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
for (const kind of ["view", "materializedView"]) {
|
|
2355
|
+
for (const object of ordered) {
|
|
2356
|
+
if (object.kind !== kind || object.owner === "ignored")
|
|
2357
|
+
continue;
|
|
2358
|
+
const sql = createObjectSql(object, schema);
|
|
2359
|
+
if (sql !== undefined)
|
|
2360
|
+
statements.push(sql);
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
for (const object of ordered) {
|
|
2364
|
+
if (!ownedByView(object) || object.owner === "ignored")
|
|
2365
|
+
continue;
|
|
2366
|
+
const sql = createObjectSql(object, schema);
|
|
2367
|
+
if (sql !== undefined)
|
|
2368
|
+
statements.push(sql);
|
|
2369
|
+
}
|
|
2370
|
+
return statements;
|
|
2371
|
+
}
|
|
2372
|
+
function uniqueBeforeForeignKey(objects) {
|
|
2373
|
+
const uniques = objects.filter((object) => object.kind === "constraint" && object.definition.constraintKind === "unique");
|
|
2374
|
+
if (uniques.length === 0)
|
|
2375
|
+
return objects;
|
|
2376
|
+
const emitted = new Set;
|
|
2377
|
+
const result = [];
|
|
2378
|
+
for (const object of objects) {
|
|
2379
|
+
if (emitted.has(object))
|
|
2380
|
+
continue;
|
|
2381
|
+
if (object.kind === "constraint" && object.definition.constraintKind === "foreignKey") {
|
|
2382
|
+
const target = object.definition.references;
|
|
2383
|
+
if (target !== undefined && !coveredByPrimary(objects, target.parent, target.columns)) {
|
|
2384
|
+
const columns = target.columns.join("\x00");
|
|
2385
|
+
for (const unique of uniques) {
|
|
2386
|
+
if (emitted.has(unique))
|
|
2387
|
+
continue;
|
|
2388
|
+
if (!sameRef2(unique.identity.parent, target.parent))
|
|
2389
|
+
continue;
|
|
2390
|
+
if (unique.definition.columns.join("\x00") !== columns)
|
|
2391
|
+
continue;
|
|
2392
|
+
result.push(unique);
|
|
2393
|
+
emitted.add(unique);
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
result.push(object);
|
|
2398
|
+
emitted.add(object);
|
|
2399
|
+
}
|
|
2400
|
+
return result;
|
|
2401
|
+
}
|
|
2402
|
+
function coveredByPrimary(objects, parent, columns) {
|
|
2403
|
+
const key = columns.join("\x00");
|
|
2404
|
+
return objects.some((object) => object.kind === "constraint" && object.definition.constraintKind === "primaryKey" && sameRef2(object.identity.parent, parent) && object.definition.columns.join("\x00") === key);
|
|
2405
|
+
}
|
|
2406
|
+
function sameRef2(left, right) {
|
|
2407
|
+
if (left.name !== right.name || left.namespace.form !== right.namespace.form)
|
|
2408
|
+
return false;
|
|
2409
|
+
if (left.namespace.form === "static" && right.namespace.form === "static") {
|
|
2410
|
+
return left.namespace.name === right.namespace.name;
|
|
2411
|
+
}
|
|
2412
|
+
return left.namespace.form === "template" && right.namespace.form === "template" ? left.namespace.pattern === right.namespace.pattern : false;
|
|
2413
|
+
}
|
|
2414
|
+
function ownedByView(object) {
|
|
2415
|
+
if (object.kind !== "index")
|
|
2416
|
+
return false;
|
|
2417
|
+
return object.dependencies.some((edge) => edge.target.kind === "view" || edge.target.kind === "materializedView");
|
|
2418
|
+
}
|
|
2419
|
+
function createObjectSql(object, schema) {
|
|
2420
|
+
switch (object.kind) {
|
|
2421
|
+
case "column":
|
|
2422
|
+
return `alter table ${qualify(schema, object.identity.parent.name)} add column ${columnSql(object)}`;
|
|
2423
|
+
case "index":
|
|
2424
|
+
return createIndexSql(object, schema);
|
|
2425
|
+
case "constraint":
|
|
2426
|
+
return `alter table ${qualify(schema, object.identity.parent.name)} add constraint ${quoteIdent2(object.identity.name)} ${constraintBody(object, schema)}`;
|
|
2427
|
+
case "sequence":
|
|
2428
|
+
return createSequenceSql(object, schema);
|
|
2429
|
+
case "type":
|
|
2430
|
+
return createTypeSql(object, schema);
|
|
2431
|
+
case "extension":
|
|
2432
|
+
return createExtensionSql(object);
|
|
2433
|
+
case "function":
|
|
2434
|
+
return functionSql(object, schema, false);
|
|
2435
|
+
case "trigger":
|
|
2436
|
+
return triggerSql(object, schema);
|
|
2437
|
+
case "view":
|
|
2438
|
+
return viewSql(object, schema, false);
|
|
2439
|
+
case "materializedView":
|
|
2440
|
+
return materializedViewSql(object, schema);
|
|
2441
|
+
case "table":
|
|
2442
|
+
return;
|
|
2443
|
+
default:
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
function functionSql(object, schema, replace) {
|
|
2448
|
+
const definition = object.definition;
|
|
2449
|
+
const args = definition.arguments.map((argument) => `${quoteIdent2(argument.name)} ${argument.type}`).join(", ");
|
|
2450
|
+
const head = `${replace ? "create or replace" : "create"} function ${qualify(schema, object.identity.name)}(${args})`;
|
|
2451
|
+
const security = ` security ${definition.security}`;
|
|
2452
|
+
const path = definition.searchPath === undefined ? "" : ` set search_path to ${definition.searchPath}`;
|
|
2453
|
+
const tail = `returns ${definition.returns} language ${definition.language} ${definition.volatility}${security}${path}`;
|
|
2454
|
+
if (definition.atomic)
|
|
2455
|
+
return `${head} ${tail} ${definition.body}`;
|
|
2456
|
+
return `${head} ${tail} as ${dollarQuote(definition.body)}`;
|
|
2457
|
+
}
|
|
2458
|
+
function viewSql(object, schema, replace) {
|
|
2459
|
+
const verb = replace ? "create or replace view" : "create view";
|
|
2460
|
+
const invoker = object.definition.securityInvoker === true ? " with (security_invoker = true)" : "";
|
|
2461
|
+
return `${verb} ${qualify(schema, object.identity.name)}${invoker} as ${object.definition.query}`;
|
|
2462
|
+
}
|
|
2463
|
+
function policyCreatePlan(object, schema) {
|
|
2464
|
+
const table = qualify(schema, object.identity.parent.name);
|
|
2465
|
+
const name = quoteIdent2(object.identity.name);
|
|
2466
|
+
const command = object.definition.command === "all" ? "all" : "select";
|
|
2467
|
+
const check = object.definition.command === "all" ? ` with check ${object.definition.expression}` : "";
|
|
2468
|
+
const create = {
|
|
2469
|
+
sql: `create policy ${name} on ${table} as permissive for ${command} using ${object.definition.expression}${check}`,
|
|
2470
|
+
kind: "create-policy"
|
|
2471
|
+
};
|
|
2472
|
+
if (object.definition.command !== "all")
|
|
2473
|
+
return [create];
|
|
2474
|
+
return [
|
|
2475
|
+
{ sql: `alter table ${table} enable row level security`, kind: "enable-rls" },
|
|
2476
|
+
{ sql: `alter table ${table} force row level security`, kind: "enable-rls" },
|
|
2477
|
+
create
|
|
2478
|
+
];
|
|
2479
|
+
}
|
|
2480
|
+
function materializedViewSql(object, schema) {
|
|
2481
|
+
return `create materialized view ${qualify(schema, object.identity.name)} as ${object.definition.query} with no data`;
|
|
2482
|
+
}
|
|
2483
|
+
function triggerSql(object, schema) {
|
|
2484
|
+
const definition = object.definition;
|
|
2485
|
+
const timing = definition.timing === "instead" ? "instead of" : definition.timing;
|
|
2486
|
+
const events = definition.events.map((event) => {
|
|
2487
|
+
if (event !== "update" || definition.updateOf === undefined)
|
|
2488
|
+
return event;
|
|
2489
|
+
return `update of ${definition.updateOf.map((column) => quoteIdent2(column)).join(", ")}`;
|
|
2490
|
+
}).join(" or ");
|
|
2491
|
+
const when = definition.when === undefined ? "" : ` when (${definition.when})`;
|
|
2492
|
+
const args = definition.calls.argTypes.join(", ");
|
|
2493
|
+
const fn = `${qualify(schema, definition.calls.name)}(${args})`;
|
|
2494
|
+
return `create trigger ${quoteIdent2(object.identity.name)} ${timing} ${events} on ${qualify(schema, object.identity.parent.name)} for each ${definition.level}${when} execute function ${fn}`;
|
|
2495
|
+
}
|
|
2496
|
+
function dollarQuote(body) {
|
|
2497
|
+
let tag = "okm";
|
|
2498
|
+
while (body.includes(`$${tag}$`))
|
|
2499
|
+
tag = `${tag}_`;
|
|
2500
|
+
return `$${tag}$${body}$${tag}$`;
|
|
2501
|
+
}
|
|
2502
|
+
function identitySequence(sequence, source) {
|
|
2503
|
+
const key = identityKey(sequence.identity);
|
|
2504
|
+
return source.objects.some((object) => {
|
|
2505
|
+
if (object.kind !== "column" || object.definition.identity === undefined)
|
|
2506
|
+
return false;
|
|
2507
|
+
return object.dependencies.some((edge) => identityKey(edge.target) === key);
|
|
2508
|
+
});
|
|
2509
|
+
}
|
|
2510
|
+
function foldedKeys(source) {
|
|
2511
|
+
const keys = new Set;
|
|
2512
|
+
for (const object of source.objects) {
|
|
2513
|
+
if (object.kind === "column")
|
|
2514
|
+
keys.add(identityKey(object.identity));
|
|
2515
|
+
if (object.kind === "constraint" && object.definition.constraintKind === "primaryKey") {
|
|
2516
|
+
keys.add(identityKey(object.identity));
|
|
2517
|
+
}
|
|
2518
|
+
if (object.kind === "sequence" && identitySequence(object, source)) {
|
|
2519
|
+
keys.add(identityKey(object.identity));
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
return keys;
|
|
2523
|
+
}
|
|
2524
|
+
function createTableSql(tableObject, source, schema) {
|
|
2525
|
+
const parent = tableObject.identity.name;
|
|
2526
|
+
const columns = source.objects.filter((object) => object.kind === "column" && object.identity.parent.name === parent);
|
|
2527
|
+
const primary = source.objects.find((object) => object.kind === "constraint" && object.definition.constraintKind === "primaryKey" && object.identity.parent.name === parent);
|
|
2528
|
+
const lines = columns.map((column) => columnSql(column));
|
|
2529
|
+
if (primary !== undefined) {
|
|
2530
|
+
const cols = primary.definition.columns.map((name) => quoteIdent2(name)).join(", ");
|
|
2531
|
+
lines.push(`constraint ${quoteIdent2(primary.identity.name)} primary key (${cols})`);
|
|
2532
|
+
}
|
|
2533
|
+
const partition = tableObject.definition.partition;
|
|
2534
|
+
const tail = partition === undefined ? "" : ` partition by ${partition.method} (${partition.columns.map((name) => quoteIdent2(name)).join(", ")})`;
|
|
2535
|
+
return `create table ${qualify(schema, parent)} (
|
|
2536
|
+
${lines.join(`,
|
|
2537
|
+
`)}
|
|
2538
|
+
)${tail}`;
|
|
2539
|
+
}
|
|
2540
|
+
function collateSql(collation) {
|
|
2541
|
+
if (collation === undefined)
|
|
2542
|
+
return "";
|
|
2543
|
+
return ` collate ${quoteIdent2(collation)}`;
|
|
2544
|
+
}
|
|
2545
|
+
function createTypeSql(object, schema) {
|
|
2546
|
+
if (isDomain(object.definition)) {
|
|
2547
|
+
const name = object.identity.name;
|
|
2548
|
+
const constraint = quoteIdent2(fitIdentifier(`${name}_check`));
|
|
2549
|
+
return `create domain ${qualify(schema, name)} as ${object.definition.base} constraint ${constraint} check (${object.definition.check})`;
|
|
2550
|
+
}
|
|
2551
|
+
const labels = object.definition.labels.map((label) => quoteLiteral(label)).join(", ");
|
|
2552
|
+
return `create type ${qualify(schema, object.identity.name)} as enum (${labels})`;
|
|
2553
|
+
}
|
|
2554
|
+
function columnSql(column) {
|
|
2555
|
+
const definition = column.definition;
|
|
2556
|
+
let sql = `${quoteIdent2(column.identity.name)} ${definition.dataType}${collateSql(definition.collation)}`;
|
|
2557
|
+
if (definition.identity !== undefined) {
|
|
2558
|
+
sql += definition.identity.always ? " generated always as identity" : " generated by default as identity";
|
|
2559
|
+
} else if (definition.generated !== undefined) {
|
|
2560
|
+
sql += ` generated always as (${definition.generated.expression}) stored`;
|
|
2561
|
+
}
|
|
2562
|
+
if (!definition.nullable)
|
|
2563
|
+
sql += " not null";
|
|
2564
|
+
if (definition.defaultExpression !== undefined)
|
|
2565
|
+
sql += ` default ${definition.defaultExpression}`;
|
|
2566
|
+
return sql;
|
|
2567
|
+
}
|
|
2568
|
+
function createIndexSql(object, schema) {
|
|
2569
|
+
const unique = object.definition.unique ? "unique " : "";
|
|
2570
|
+
const where = object.definition.predicate === undefined ? "" : ` where ${object.definition.predicate}`;
|
|
2571
|
+
const expression = object.definition.expression;
|
|
2572
|
+
const name = quoteIdent2(object.identity.name);
|
|
2573
|
+
const on = qualify(schema, object.identity.parent.name);
|
|
2574
|
+
if (expression !== undefined && expression.startsWith("using ")) {
|
|
2575
|
+
return `create ${unique}index ${name} on ${on} ${expression}${where}`;
|
|
2576
|
+
}
|
|
2577
|
+
const target = expression !== undefined ? `(${expression})` : object.definition.columns.map((column) => quoteIdent2(column)).join(", ");
|
|
2578
|
+
return `create ${unique}index ${name} on ${on} (${target})${where}`;
|
|
2579
|
+
}
|
|
2580
|
+
function createExtensionSql(object) {
|
|
2581
|
+
const version = object.definition.version;
|
|
2582
|
+
const pinned = version !== undefined && /^\d+(?:\.\d+)*$/.test(version) ? ` version ${quoteLiteral(version)}` : "";
|
|
2583
|
+
return `create extension ${quoteIdent2(object.identity.name)} schema ${quoteIdent2(object.definition.schema)}${pinned}`;
|
|
2584
|
+
}
|
|
2585
|
+
function createSequenceSql(object, schema) {
|
|
2586
|
+
const definition = object.definition;
|
|
2587
|
+
const cycle = definition.cycle ? " cycle" : "";
|
|
2588
|
+
return `create sequence ${qualify(schema, object.identity.name)} as ${definition.dataType} start ${definition.start} increment ${definition.increment}${cycle}`;
|
|
2589
|
+
}
|
|
2590
|
+
function referenceSchema(object, schema) {
|
|
2591
|
+
const references = object.definition.references;
|
|
2592
|
+
if (references === undefined)
|
|
2593
|
+
return schema;
|
|
2594
|
+
const target = references.parent.namespace;
|
|
2595
|
+
const parent = object.identity.parent.namespace;
|
|
2596
|
+
if (target.form === "static" && parent.form === "static" && target.name !== parent.name) {
|
|
2597
|
+
return target.name;
|
|
2598
|
+
}
|
|
2599
|
+
return schema;
|
|
2600
|
+
}
|
|
2601
|
+
function constraintBody(object, schema) {
|
|
2602
|
+
const definition = object.definition;
|
|
2603
|
+
const columns = definition.columns.map((name) => quoteIdent2(name)).join(", ");
|
|
2604
|
+
switch (definition.constraintKind) {
|
|
2605
|
+
case "primaryKey":
|
|
2606
|
+
return `primary key (${columns})`;
|
|
2607
|
+
case "unique": {
|
|
2608
|
+
const nulls = definition.nullsNotDistinct ? " nulls not distinct" : "";
|
|
2609
|
+
return `unique${nulls} (${columns})${deferClause(definition)}`;
|
|
2610
|
+
}
|
|
2611
|
+
case "check":
|
|
2612
|
+
return `check (${definition.expression ?? "true"})${deferClause(definition)}`;
|
|
2613
|
+
case "foreignKey": {
|
|
2614
|
+
const references = definition.references;
|
|
2615
|
+
const target = references === undefined ? "" : ` references ${qualify(referenceSchema(object, schema), references.parent.name)} (${references.columns.map((name) => quoteIdent2(name)).join(", ")})`;
|
|
2616
|
+
const onDelete = references?.onDelete === undefined ? "" : ` on delete ${references.onDelete}`;
|
|
2617
|
+
const onUpdate = references?.onUpdate === undefined ? "" : ` on update ${references.onUpdate}`;
|
|
2618
|
+
return `foreign key (${columns})${target}${onDelete}${onUpdate}${deferClause(definition)}`;
|
|
2619
|
+
}
|
|
2620
|
+
default:
|
|
2621
|
+
return definition.constraintKind;
|
|
2622
|
+
}
|
|
2623
|
+
}
|
|
2624
|
+
function deferClause(definition) {
|
|
2625
|
+
if (!definition.deferrable)
|
|
2626
|
+
return "";
|
|
2627
|
+
return ` deferrable initially ${definition.initially}`;
|
|
2628
|
+
}
|
|
2629
|
+
function qualify(schema, name) {
|
|
2630
|
+
return `${quoteIdent2(schema)}.${quoteIdent2(name)}`;
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2288
2633
|
// src/dialects/pg/floor.ts
|
|
2289
2634
|
var POSTGRES_FLOOR = 15;
|
|
2290
2635
|
var UUIDV7_POSTGRES = 18;
|
|
@@ -2363,24 +2708,6 @@ function rejected(message) {
|
|
|
2363
2708
|
throw new OkmError(CODEC_VALUE_CODE, message);
|
|
2364
2709
|
}
|
|
2365
2710
|
|
|
2366
|
-
// src/dialects/pg/quote.ts
|
|
2367
|
-
function quoteLiteral(value) {
|
|
2368
|
-
return `'${value.replaceAll("'", "''")}'`;
|
|
2369
|
-
}
|
|
2370
|
-
function arrayElement(encoded, raw) {
|
|
2371
|
-
if (raw && (encoded === "true" || encoded === "false" || isBareNumber(encoded))) {
|
|
2372
|
-
return encoded;
|
|
2373
|
-
}
|
|
2374
|
-
return `"${encoded.replaceAll("\\", "\\\\").replaceAll('"', "\\\"")}"`;
|
|
2375
|
-
}
|
|
2376
|
-
function isBareNumber(encoded) {
|
|
2377
|
-
let pattern = bareNumber;
|
|
2378
|
-
pattern ??= /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
2379
|
-
bareNumber = pattern;
|
|
2380
|
-
return pattern.test(encoded);
|
|
2381
|
-
}
|
|
2382
|
-
var bareNumber;
|
|
2383
|
-
|
|
2384
2711
|
// src/dialects/pg/array-literal.ts
|
|
2385
2712
|
function writeArray(value, dims, encode, raw) {
|
|
2386
2713
|
return writeLevel(value, dims, encode, raw);
|
|
@@ -3786,4 +4113,4 @@ function postgresUrl(port) {
|
|
|
3786
4113
|
return `postgres://${USER}:${PASSWORD}@${HOST}:${port}/${DATABASE}`;
|
|
3787
4114
|
}
|
|
3788
4115
|
|
|
3789
|
-
export { OkmError, safe, catalogError, throwNamed, DriverError2, cancelled2, timedOut2, outcomeUnknown2, acquireTimeout2, errorField2, mapDriverError2, isConnectionSqlstate, isConnectionErrno, isConnectionFailure, isConnectionLost, mapPostgresError2, assertIdentifier, fitIdentifier, assertStoredText, staticNamespace, identityKey, identityLabel, sameNamespace, CATALOG_VERSION, table, column, index, constraint, sequence, compareText, enumType, domainType,
|
|
4116
|
+
export { OkmError, safe, catalogError, throwNamed, DriverError2, cancelled2, timedOut2, outcomeUnknown2, acquireTimeout2, errorField2, mapDriverError2, isConnectionSqlstate, isConnectionErrno, isConnectionFailure, isConnectionLost, mapPostgresError2, assertIdentifier, fitIdentifier, assertStoredText, staticNamespace, identityKey, identityLabel, sameNamespace, CATALOG_VERSION, table, column, index, constraint, sequence, compareText, enumType, domainType, sameEnumLabels, indexObjects, orderIndexed, creationOrder2, catalogHash2, loadTrustedCatalog2, catalogFileText2, quoteLiteral, quoteIdent2, renderCatalog2, clientGenerator, readClientGenerator, definition, unavailable, rejected, writeArray, ColumnBuilder, required, openColumn, formatType, retarget, POSTGRES_FLOOR, UUIDV7_POSTGRES, isPostgresMajor, parsePostgresFloor, formatPostgresFloor, minPostgresDefinition, uuidv7NeedsPostgres, serverNeedsPostgres, isOperator, operatorName, operatorValue, tag, json, jsonb, encodeJson, safetyInstalled, runSafety, withRowFilters, archiveRules, readOptionNames, installOperatorSql, readNeedsOperatorSql, orderHasRelevance, emitRelationFrom, needsOperatorSql, bindCall, compileCall, decodeResult, logicalIntent, appliedRules, emitJoin, emitWhere, emitOrder, emitPrimaryOrder, refuseHidden, emitLimit, selectedColumns, parseOrder, rejectKeys, readLimit, takeObject, projectExpr, jsonExpr, decodeRow, cell, indexes, quote, list, isRecord, orFail, registerFailFix, fail2, primaryUrl };
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
readHandle,
|
|
4
4
|
readCall,
|
|
5
5
|
attachHttp
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./jr2nmr81.js";
|
|
7
7
|
import {
|
|
8
8
|
OkmError,
|
|
9
9
|
throwNamed,
|
|
10
10
|
fail2
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./hfq3n3bd.js";
|
|
12
12
|
|
|
13
13
|
// src/runtime/lock.ts
|
|
14
14
|
var LOCKS = ["update", "share"];
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
expectOf2,
|
|
16
16
|
allowSet2,
|
|
17
17
|
noteGuarded2
|
|
18
|
-
} from "./
|
|
19
|
-
import"./
|
|
20
|
-
import"./
|
|
18
|
+
} from "./ezqn88nj.js";
|
|
19
|
+
import"./w5d89rb4.js";
|
|
20
|
+
import"./35zemrmf.js";
|
|
21
21
|
export {
|
|
22
22
|
Sql2 as Sql,
|
|
23
23
|
WRITE_PARAM_BUDGET2 as WRITE_PARAM_BUDGET,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
logicalIntent,
|
|
12
12
|
appliedRules,
|
|
13
13
|
rejectKeys
|
|
14
|
-
} from "./
|
|
14
|
+
} from "./hfq3n3bd.js";
|
|
15
15
|
|
|
16
16
|
// src/runtime/client.ts
|
|
17
17
|
var PLAN_LIMIT = 64;
|
|
@@ -84,7 +84,7 @@ function openClient(session) {
|
|
|
84
84
|
},
|
|
85
85
|
close,
|
|
86
86
|
connected: session.connected,
|
|
87
|
-
tx: (...args) => import("./
|
|
87
|
+
tx: (...args) => import("./stebqyyd.js").then((mod) => mod.tx(session, args)),
|
|
88
88
|
batch: (ops, options) => batchHandle(session, ops, options),
|
|
89
89
|
...session.tx?.extras
|
|
90
90
|
};
|
|
@@ -119,7 +119,7 @@ function tableApi(session, table, view, uses) {
|
|
|
119
119
|
const api = {
|
|
120
120
|
find(options = {}) {
|
|
121
121
|
if ("lock" in options) {
|
|
122
|
-
return lazyRead(session, () => import("./
|
|
122
|
+
return lazyRead(session, () => import("./j664qjrt.js"), table, options, base, view);
|
|
123
123
|
}
|
|
124
124
|
return start(session, "find", table, options, base, view);
|
|
125
125
|
},
|
|
@@ -133,10 +133,10 @@ function tableApi(session, table, view, uses) {
|
|
|
133
133
|
return start(session, "exists", table, options, base, view);
|
|
134
134
|
},
|
|
135
135
|
page(options) {
|
|
136
|
-
return lazyRead(session, () => import("./
|
|
136
|
+
return lazyRead(session, () => import("./w17sj05d.js"), table, options, base, view);
|
|
137
137
|
},
|
|
138
138
|
aggregate(options = {}) {
|
|
139
|
-
return lazyRead(session, () => import("./
|
|
139
|
+
return lazyRead(session, () => import("./7aews1zg.js"), table, options, base, view);
|
|
140
140
|
},
|
|
141
141
|
insert(data, options = {}) {
|
|
142
142
|
return writeHandle(session, "insert", table, data, options, mods);
|
|
@@ -149,9 +149,9 @@ function tableApi(session, table, view, uses) {
|
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
for (const walk of ["descendants", "ancestors"]) {
|
|
152
|
-
api[walk] = (id, options) => lazyRead(session, () => import("./
|
|
152
|
+
api[walk] = (id, options) => lazyRead(session, () => import("./m4hhb8aa.js"), table, { id, walk, options }, base, view);
|
|
153
153
|
}
|
|
154
|
-
api.sync = (id, relation, ids, options) => lazyRead(session, () => import("./
|
|
154
|
+
api.sync = (id, relation, ids, options) => lazyRead(session, () => import("./0r05zhyq.js"), table, { id, relation, ids, options }, base, view, true);
|
|
155
155
|
const hooks = session.schema.hooks;
|
|
156
156
|
if (hooks !== undefined) {
|
|
157
157
|
for (const hook of hooks) {
|
|
@@ -171,13 +171,13 @@ function tableApi(session, table, view, uses) {
|
|
|
171
171
|
return api;
|
|
172
172
|
}
|
|
173
173
|
function batchHandle(session, ops, options, replica) {
|
|
174
|
-
return queryHandle(() => import("./
|
|
174
|
+
return queryHandle(() => import("./shjs0379.js").then((mod) => mod.batch(session, ops, options, replica)), {
|
|
175
175
|
replica: () => batchHandle(session, ops, options, true)
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
178
|
var writers;
|
|
179
179
|
function loadWrite() {
|
|
180
|
-
writers ??= import("./
|
|
180
|
+
writers ??= import("./jpgmjsx3.js");
|
|
181
181
|
return writers;
|
|
182
182
|
}
|
|
183
183
|
function queryHandle(run, extra) {
|
|
@@ -287,7 +287,7 @@ function lazyRead(session, load, table, options, mods, view, sync) {
|
|
|
287
287
|
return queryHandle(() => read().then((box) => box.it), extra);
|
|
288
288
|
}
|
|
289
289
|
async function decodeRows(plan, rows, table) {
|
|
290
|
-
return plan.outputs.includes.length === 0 ? decodeResult(plan, rows, table) : (await import("./
|
|
290
|
+
return plan.outputs.includes.length === 0 ? decodeResult(plan, rows, table) : (await import("./ytk1tjs0.js")).decodeIncluded(plan, rows, table);
|
|
291
291
|
}
|
|
292
292
|
function readHandle(session, table, call, mods, decode, extra) {
|
|
293
293
|
let prepared;
|
|
@@ -297,17 +297,17 @@ function readHandle(session, table, call, mods, decode, extra) {
|
|
|
297
297
|
if (prepared !== undefined)
|
|
298
298
|
return prepared;
|
|
299
299
|
if (mods.uses !== undefined) {
|
|
300
|
-
call = (await import("./
|
|
300
|
+
call = (await import("./5bmksndh.js")).refine(session.schema, origin, mods.uses);
|
|
301
301
|
}
|
|
302
302
|
if (searched) {
|
|
303
|
-
call = (await import("./
|
|
303
|
+
call = (await import("./wbwq1jsa.js")).applyTextSearch(session.schema, call);
|
|
304
304
|
}
|
|
305
305
|
const hooks = await hooksFor(call);
|
|
306
306
|
if (readNeedsOperatorSql(session.schema, call) || hooks?.needsOperator(session.schema, call)) {
|
|
307
307
|
await loadOperatorSql();
|
|
308
308
|
}
|
|
309
309
|
if (call.build === undefined && selectHasWindow(call.select)) {
|
|
310
|
-
call = (await import("./
|
|
310
|
+
call = (await import("./c0xevn1h.js")).attach(session.schema, call);
|
|
311
311
|
}
|
|
312
312
|
const bound = bindCall(session.schema, call, hooks);
|
|
313
313
|
let plan = session.cache.get(bound.key);
|
|
@@ -337,7 +337,7 @@ function readHandle(session, table, call, mods, decode, extra) {
|
|
|
337
337
|
const mapped = await mapError(session, error);
|
|
338
338
|
if (session.schema.model[table]?.conceal !== true)
|
|
339
339
|
throw logged(session, mapped);
|
|
340
|
-
const { scrubCall } = await import("./
|
|
340
|
+
const { scrubCall } = await import("./tpssp7ac.js");
|
|
341
341
|
throw logged(session, scrubCall(mapped, session.schema, call));
|
|
342
342
|
}
|
|
343
343
|
};
|
|
@@ -370,7 +370,7 @@ function readHandle(session, table, call, mods, decode, extra) {
|
|
|
370
370
|
}
|
|
371
371
|
function streamLazy(session, call, mods, view, batch) {
|
|
372
372
|
return async function* () {
|
|
373
|
-
const { streamRows } = await import("./
|
|
373
|
+
const { streamRows } = await import("./yhp829bx.js");
|
|
374
374
|
yield* streamRows(session, call, mods, view, batch, (error) => logged(session, error));
|
|
375
375
|
}();
|
|
376
376
|
}
|
|
@@ -403,22 +403,14 @@ function readCall(op, table, options, all, scope, model, schema, view) {
|
|
|
403
403
|
};
|
|
404
404
|
}
|
|
405
405
|
async function checkServer(pool, schema, http, requireMeta, options, source) {
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
try {
|
|
409
|
-
const result = await pool.execute(server.versionQuery, undefined, options);
|
|
410
|
-
rows = result.rows;
|
|
411
|
-
} catch (error) {
|
|
412
|
-
const { mapPostgresError } = await import("./ep8zh3bk.js");
|
|
413
|
-
throw mapPostgresError(error, mapOptions(http, false, schema));
|
|
414
|
-
}
|
|
415
|
-
await server.acceptServer(pool, schema, rows, http, requireMeta, options, source);
|
|
406
|
+
const { acceptServer } = await import("./76pv6qff.js");
|
|
407
|
+
await acceptServer(pool, schema, http, requireMeta, options, source);
|
|
416
408
|
}
|
|
417
409
|
async function mapError(session, error) {
|
|
418
410
|
if (error instanceof OkmError) {
|
|
419
411
|
return session.http === undefined ? error : new OkmError(error.code, error.message, { ...errorFields(error), http: session.http });
|
|
420
412
|
}
|
|
421
|
-
const { mapPostgresError } = await import("./
|
|
413
|
+
const { mapPostgresError } = await import("./yfedr1zb.js");
|
|
422
414
|
return mapPostgresError(error, mapOptions(session.http, session.includeValues, session.schema));
|
|
423
415
|
}
|
|
424
416
|
function errorFields(error) {
|
|
@@ -432,7 +424,7 @@ function errorFields(error) {
|
|
|
432
424
|
var includeHooks;
|
|
433
425
|
var operatorSql;
|
|
434
426
|
function loadOperatorSql() {
|
|
435
|
-
operatorSql ??= import("./
|
|
427
|
+
operatorSql ??= import("./7b3xp9gc.js").then(() => {
|
|
436
428
|
return;
|
|
437
429
|
});
|
|
438
430
|
return operatorSql;
|
|
@@ -443,7 +435,7 @@ function selectHasWindow(select) {
|
|
|
443
435
|
function hooksFor(call) {
|
|
444
436
|
if (call.include === undefined)
|
|
445
437
|
return Promise.resolve(undefined);
|
|
446
|
-
includeHooks ??= import("./
|
|
438
|
+
includeHooks ??= import("./ytk1tjs0.js").then((mod) => mod.includeHooks);
|
|
447
439
|
return includeHooks;
|
|
448
440
|
}
|
|
449
441
|
function bindNow(schema, call) {
|
|
@@ -454,7 +446,7 @@ function bindNow(schema, call) {
|
|
|
454
446
|
function finish(session, view, call) {
|
|
455
447
|
if (session.schema.model[call.table]?.conceal !== true)
|
|
456
448
|
return view;
|
|
457
|
-
return import("./
|
|
449
|
+
return import("./tpssp7ac.js").then((mod) => mod.redactView(session.schema, view, call));
|
|
458
450
|
}
|
|
459
451
|
function inspection(plan, params, call, source) {
|
|
460
452
|
return {
|
|
@@ -502,4 +494,4 @@ function logged(session, error) {
|
|
|
502
494
|
return error;
|
|
503
495
|
}
|
|
504
496
|
|
|
505
|
-
export { createClient, openClient, queryHandle, decodeRows, readHandle, readCall, withHttp, attachHttp, settleCall };
|
|
497
|
+
export { createClient, openClient, queryHandle, decodeRows, readHandle, readCall, withHttp, attachHttp, mapOptions, settleCall };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DriverError2,
|
|
3
3
|
isConnectionLost
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./hfq3n3bd.js";
|
|
5
5
|
import {
|
|
6
6
|
connectClient3,
|
|
7
7
|
send4
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./am04v8na.js";
|
|
9
9
|
import {
|
|
10
10
|
resetSession2
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./7pxncnzs.js";
|
|
12
12
|
import {
|
|
13
13
|
WireSession
|
|
14
|
-
} from "./
|
|
14
|
+
} from "./jsjjz875.js";
|
|
15
15
|
import {
|
|
16
16
|
noTimeout
|
|
17
|
-
} from "./
|
|
17
|
+
} from "./3yn79q5m.js";
|
|
18
18
|
import {
|
|
19
19
|
rejectClosed,
|
|
20
20
|
runCall
|
|
21
|
-
} from "./
|
|
21
|
+
} from "./5x3pf400.js";
|
|
22
22
|
|
|
23
23
|
// src/adapters/pg/neon-extra.ts
|
|
24
24
|
async function checkout(held) {
|
|
@@ -67,7 +67,7 @@ async function checkout(held) {
|
|
|
67
67
|
if (refused !== undefined)
|
|
68
68
|
return refused;
|
|
69
69
|
return guard(() => runCall(isClosed(), options, async (watch) => {
|
|
70
|
-
const { runAtomicBatch } = await import("./
|
|
70
|
+
const { runAtomicBatch } = await import("./gqwevek4.js");
|
|
71
71
|
return runAtomicBatch(session, statements, watch);
|
|
72
72
|
}));
|
|
73
73
|
},
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
send2,
|
|
5
5
|
reserve2,
|
|
6
6
|
park2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./rcywj2w8.js";
|
|
8
8
|
import {
|
|
9
9
|
BUNSQL_CAPABILITIES,
|
|
10
10
|
readCapability2,
|
|
11
11
|
hasCapability2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./5x3pf400.js";
|
|
13
13
|
export {
|
|
14
14
|
BUNSQL_CAPABILITIES as capabilities,
|
|
15
15
|
hasCapability2 as hasCapability,
|