@prisma-next/adapter-postgres 0.15.0-dev.1 → 0.15.0-dev.11
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/dist/{adapter-CssyjkaR.mjs → adapter-Bh8GA6sC.mjs} +2 -2
- package/dist/{adapter-CssyjkaR.mjs.map → adapter-Bh8GA6sC.mjs.map} +1 -1
- package/dist/adapter.mjs +1 -1
- package/dist/{control-adapter-w2BFxQ--.mjs → control-adapter-aFfSI2bK.mjs} +118 -60
- package/dist/control-adapter-aFfSI2bK.mjs.map +1 -0
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +1 -1
- package/dist/runtime.mjs +1 -1
- package/package.json +23 -23
- package/src/core/control-adapter.ts +130 -60
- package/dist/control-adapter-w2BFxQ--.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as renderLoweredSql, r as createPostgresBuiltinCodecLookup, t as PostgresControlAdapter } from "./control-adapter-
|
|
1
|
+
import { n as renderLoweredSql, r as createPostgresBuiltinCodecLookup, t as PostgresControlAdapter } from "./control-adapter-aFfSI2bK.mjs";
|
|
2
2
|
import { APP_SPACE_ID } from "@prisma-next/framework-components/control";
|
|
3
3
|
import { isDdlNode } from "@prisma-next/sql-relational-core/ast";
|
|
4
4
|
//#region src/core/adapter.ts
|
|
@@ -63,4 +63,4 @@ function createPostgresAdapter(options) {
|
|
|
63
63
|
//#endregion
|
|
64
64
|
export { postgresRawCodecInferer as n, createPostgresAdapter as t };
|
|
65
65
|
|
|
66
|
-
//# sourceMappingURL=adapter-
|
|
66
|
+
//# sourceMappingURL=adapter-Bh8GA6sC.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-
|
|
1
|
+
{"version":3,"file":"adapter-Bh8GA6sC.mjs","names":[],"sources":["../src/core/adapter.ts"],"sourcesContent":["import type { CodecRegistry } from '@prisma-next/framework-components/codec';\nimport { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport type {\n Adapter,\n AdapterProfile,\n AnyQueryAst,\n LowererContext,\n RawSqlLiteral,\n SqlQueryable,\n} from '@prisma-next/sql-relational-core/ast';\nimport { isDdlNode } from '@prisma-next/sql-relational-core/ast';\nimport type { RawCodecInferer } from '@prisma-next/sql-relational-core/expression';\nimport type { PostgresDdlNode } from '@prisma-next/target-postgres/ddl';\nimport { createPostgresBuiltinCodecLookup } from './codec-lookup';\nimport { PostgresControlAdapter } from './control-adapter';\nimport { renderLoweredSql } from './sql-renderer';\nimport type { PostgresAdapterOptions, PostgresContract, PostgresLoweredStatement } from './types';\n\nconst defaultCapabilities = Object.freeze({\n postgres: {\n orderBy: true,\n limit: true,\n lateral: true,\n jsonAgg: true,\n returning: true,\n distinctOn: true,\n },\n sql: {\n enums: true,\n returning: true,\n defaultInInsert: true,\n lateral: true,\n scalarList: true,\n },\n});\n\nclass PostgresAdapterImpl\n implements Adapter<AnyQueryAst, PostgresContract, PostgresLoweredStatement>\n{\n // These fields make the adapter instance structurally compatible with RuntimeAdapterInstance<'sql', 'postgres'> without introducing a runtime-plane dependency.\n readonly familyId = 'sql' as const;\n readonly targetId = 'postgres' as const;\n\n readonly profile: AdapterProfile<'postgres'>;\n private readonly codecLookup: CodecRegistry;\n\n constructor(options?: PostgresAdapterOptions) {\n this.codecLookup = options?.codecLookup ?? createPostgresBuiltinCodecLookup();\n const controlAdapter = new PostgresControlAdapter(this.codecLookup);\n this.profile = Object.freeze({\n id: options?.profileId ?? 'postgres/default@1',\n target: 'postgres',\n capabilities: defaultCapabilities,\n readMarker: (queryable: SqlQueryable) =>\n controlAdapter.readMarkerDiscriminated(\n {\n familyId: 'sql',\n targetId: 'postgres',\n query: async <Row = Record<string, unknown>>(\n sql: string,\n params?: readonly unknown[],\n ) => {\n const result = await queryable.query<Row>(sql, params);\n return { rows: [...result.rows] };\n },\n close: async () => {},\n },\n APP_SPACE_ID,\n ),\n });\n }\n\n lower(\n ast: AnyQueryAst | PostgresDdlNode,\n context: LowererContext<PostgresContract>,\n ): PostgresLoweredStatement {\n if (isDdlNode(ast)) {\n throw new Error(\n 'lower() does not lower DDL on the runtime adapter — DDL lowering is a control-plane concern handled by the control adapter.',\n );\n }\n return renderLoweredSql(ast, context.contract, this.codecLookup);\n }\n}\n\n/** Codec-id lookup for bare-literal interpolations used by `fns.raw` on a postgres client. Contributed as the descriptor's static `rawCodecInferer` slot. */\nexport const postgresRawCodecInferer: RawCodecInferer = {\n inferCodec(value: RawSqlLiteral): string {\n switch (typeof value) {\n case 'number':\n return Number.isSafeInteger(value) && value % 1 === 0 ? 'pg/int4' : 'pg/float8';\n case 'bigint':\n return 'pg/int8';\n case 'string':\n return 'pg/text';\n case 'boolean':\n return 'pg/bool';\n case 'object':\n if (value instanceof Uint8Array) return 'pg/bytea';\n }\n throw new Error(\n 'unsupported JS value type for raw-SQL interpolation: wrap this value in `param(...)` with an explicit codec',\n );\n },\n};\n\nexport function createPostgresAdapter(options?: PostgresAdapterOptions) {\n return Object.freeze(new PostgresAdapterImpl(options));\n}\n"],"mappings":";;;;AAkBA,MAAM,sBAAsB,OAAO,OAAO;CACxC,UAAU;EACR,SAAS;EACT,OAAO;EACP,SAAS;EACT,SAAS;EACT,WAAW;EACX,YAAY;CACd;CACA,KAAK;EACH,OAAO;EACP,WAAW;EACX,iBAAiB;EACjB,SAAS;EACT,YAAY;CACd;AACF,CAAC;AAED,IAAM,sBAAN,MAEA;CAEE,WAAoB;CACpB,WAAoB;CAEpB;CACA;CAEA,YAAY,SAAkC;EAC5C,KAAK,cAAc,SAAS,eAAe,iCAAiC;EAC5E,MAAM,iBAAiB,IAAI,uBAAuB,KAAK,WAAW;EAClE,KAAK,UAAU,OAAO,OAAO;GAC3B,IAAI,SAAS,aAAa;GAC1B,QAAQ;GACR,cAAc;GACd,aAAa,cACX,eAAe,wBACb;IACE,UAAU;IACV,UAAU;IACV,OAAO,OACL,KACA,WACG;KAEH,OAAO,EAAE,MAAM,CAAC,IAAG,MADE,UAAU,MAAW,KAAK,MAAM,EAAA,CAC3B,IAAI,EAAE;IAClC;IACA,OAAO,YAAY,CAAC;GACtB,GACA,YACF;EACJ,CAAC;CACH;CAEA,MACE,KACA,SAC0B;EAC1B,IAAI,UAAU,GAAG,GACf,MAAM,IAAI,MACR,6HACF;EAEF,OAAO,iBAAiB,KAAK,QAAQ,UAAU,KAAK,WAAW;CACjE;AACF;;AAGA,MAAa,0BAA2C,EACtD,WAAW,OAA8B;CACvC,QAAQ,OAAO,OAAf;EACE,KAAK,UACH,OAAO,OAAO,cAAc,KAAK,KAAK,QAAQ,MAAM,IAAI,YAAY;EACtE,KAAK,UACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,UACH,IAAI,iBAAiB,YAAY,OAAO;CAC5C;CACA,MAAM,IAAI,MACR,6GACF;AACF,EACF;AAEA,SAAgB,sBAAsB,SAAkC;CACtE,OAAO,OAAO,OAAO,IAAI,oBAAoB,OAAO,CAAC;AACvD"}
|
package/dist/adapter.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as postgresRawCodecInferer, t as createPostgresAdapter } from "./adapter-
|
|
1
|
+
import { n as postgresRawCodecInferer, t as createPostgresAdapter } from "./adapter-Bh8GA6sC.mjs";
|
|
2
2
|
export { createPostgresAdapter, postgresRawCodecInferer };
|
|
@@ -5,12 +5,13 @@ import { parseMarkerRowSafely, rethrowMarkerReadError, withMarkerReadErrorHandli
|
|
|
5
5
|
import { parseContractMarkerRow } from "@prisma-next/family-sql/verify";
|
|
6
6
|
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
7
7
|
import { REFERENTIAL_ACTION_SQL } from "@prisma-next/sql-contract/referential-action-sql";
|
|
8
|
+
import { RelationalSchemaNodeKind } from "@prisma-next/sql-schema-ir/types";
|
|
8
9
|
import { buildControlTableBootstrapQueries, buildSignMarkerBootstrapQueries, int4, int8, jsonb, pgTable, text, textArray, timestamptz } from "@prisma-next/target-postgres/contract-free";
|
|
9
10
|
import { parsePostgresDefault } from "@prisma-next/target-postgres/default-normalizer";
|
|
10
11
|
import { normalizeSchemaNativeType } from "@prisma-next/target-postgres/native-type-normalizer";
|
|
11
12
|
import { parseRlsPolicyWireName } from "@prisma-next/target-postgres/rls-canonicalize";
|
|
12
13
|
import { escapeLiteral, quoteIdentifier } from "@prisma-next/target-postgres/sql-utils";
|
|
13
|
-
import { PostgresDatabaseSchemaNode, PostgresNamespaceSchemaNode, PostgresNativeEnumSchemaNode, PostgresPolicySchemaNode, PostgresRoleSchemaNode, PostgresTableSchemaNode } from "@prisma-next/target-postgres/types";
|
|
14
|
+
import { PostgresDatabaseSchemaNode, PostgresNamespaceSchemaNode, PostgresNativeEnumSchemaNode, PostgresPolicySchemaNode, PostgresRoleSchemaNode, PostgresSchemaNodeKind, PostgresTableSchemaNode } from "@prisma-next/target-postgres/types";
|
|
14
15
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
15
16
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
16
17
|
import { createAstCodecRegistry, deriveParamMetadata, encodeParamsWithMetadata } from "@prisma-next/sql-runtime";
|
|
@@ -1013,64 +1014,74 @@ var PostgresControlAdapter = class {
|
|
|
1013
1014
|
WHERE c.table_schema = $1
|
|
1014
1015
|
ORDER BY c.table_name, c.ordinal_position`, [schema]);
|
|
1015
1016
|
const pkResult = await driver.query(`SELECT
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
FROM
|
|
1021
|
-
JOIN
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
AND
|
|
1027
|
-
|
|
1017
|
+
cl.relname AS table_name,
|
|
1018
|
+
con.conname AS constraint_name,
|
|
1019
|
+
a.attname AS column_name,
|
|
1020
|
+
k.ord AS ordinal_position
|
|
1021
|
+
FROM pg_catalog.pg_constraint con
|
|
1022
|
+
JOIN pg_catalog.pg_class cl ON cl.oid = con.conrelid
|
|
1023
|
+
JOIN pg_catalog.pg_namespace ns ON ns.oid = cl.relnamespace
|
|
1024
|
+
JOIN LATERAL unnest(con.conkey) WITH ORDINALITY AS k(attnum, ord) ON true
|
|
1025
|
+
JOIN pg_catalog.pg_attribute a
|
|
1026
|
+
ON a.attrelid = con.conrelid
|
|
1027
|
+
AND a.attnum = k.attnum
|
|
1028
|
+
WHERE ns.nspname = $1
|
|
1029
|
+
AND con.contype = 'p'
|
|
1030
|
+
ORDER BY cl.relname, k.ord`, [schema]);
|
|
1028
1031
|
const fkResult = await driver.query(`SELECT
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1032
|
+
cl.relname AS table_name,
|
|
1033
|
+
con.conname AS constraint_name,
|
|
1034
|
+
a.attname AS column_name,
|
|
1035
|
+
k.ord AS ordinal_position,
|
|
1033
1036
|
ref_ns.nspname AS referenced_table_schema,
|
|
1034
1037
|
ref_cl.relname AS referenced_table_name,
|
|
1035
1038
|
ref_att.attname AS referenced_column_name,
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1039
|
+
CASE con.confdeltype
|
|
1040
|
+
WHEN 'a' THEN 'NO ACTION'
|
|
1041
|
+
WHEN 'r' THEN 'RESTRICT'
|
|
1042
|
+
WHEN 'c' THEN 'CASCADE'
|
|
1043
|
+
WHEN 'n' THEN 'SET NULL'
|
|
1044
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
|
1045
|
+
END AS delete_rule,
|
|
1046
|
+
CASE con.confupdtype
|
|
1047
|
+
WHEN 'a' THEN 'NO ACTION'
|
|
1048
|
+
WHEN 'r' THEN 'RESTRICT'
|
|
1049
|
+
WHEN 'c' THEN 'CASCADE'
|
|
1050
|
+
WHEN 'n' THEN 'SET NULL'
|
|
1051
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
|
1052
|
+
END AS update_rule
|
|
1053
|
+
FROM pg_catalog.pg_constraint con
|
|
1054
|
+
JOIN pg_catalog.pg_class cl ON cl.oid = con.conrelid
|
|
1055
|
+
JOIN pg_catalog.pg_namespace ns ON ns.oid = cl.relnamespace
|
|
1056
|
+
JOIN LATERAL unnest(con.conkey) WITH ORDINALITY AS k(attnum, ord) ON true
|
|
1057
|
+
JOIN pg_catalog.pg_attribute a
|
|
1058
|
+
ON a.attrelid = con.conrelid
|
|
1059
|
+
AND a.attnum = k.attnum
|
|
1048
1060
|
JOIN pg_catalog.pg_class ref_cl
|
|
1049
|
-
ON ref_cl.oid =
|
|
1061
|
+
ON ref_cl.oid = con.confrelid
|
|
1050
1062
|
JOIN pg_catalog.pg_namespace ref_ns
|
|
1051
1063
|
ON ref_ns.oid = ref_cl.relnamespace
|
|
1052
1064
|
JOIN pg_catalog.pg_attribute ref_att
|
|
1053
|
-
ON ref_att.attrelid =
|
|
1054
|
-
AND ref_att.attnum =
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
WHERE tc.table_schema = $1
|
|
1059
|
-
AND tc.constraint_type = 'FOREIGN KEY'
|
|
1060
|
-
ORDER BY tc.table_name, tc.constraint_name, kcu.ordinal_position`, [schema]);
|
|
1065
|
+
ON ref_att.attrelid = con.confrelid
|
|
1066
|
+
AND ref_att.attnum = con.confkey[k.ord]
|
|
1067
|
+
WHERE ns.nspname = $1
|
|
1068
|
+
AND con.contype = 'f'
|
|
1069
|
+
ORDER BY cl.relname, con.conname, k.ord`, [schema]);
|
|
1061
1070
|
const uniqueResult = await driver.query(`SELECT
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
FROM
|
|
1067
|
-
JOIN
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
AND
|
|
1073
|
-
|
|
1071
|
+
cl.relname AS table_name,
|
|
1072
|
+
con.conname AS constraint_name,
|
|
1073
|
+
a.attname AS column_name,
|
|
1074
|
+
k.ord AS ordinal_position
|
|
1075
|
+
FROM pg_catalog.pg_constraint con
|
|
1076
|
+
JOIN pg_catalog.pg_class cl ON cl.oid = con.conrelid
|
|
1077
|
+
JOIN pg_catalog.pg_namespace ns ON ns.oid = cl.relnamespace
|
|
1078
|
+
JOIN LATERAL unnest(con.conkey) WITH ORDINALITY AS k(attnum, ord) ON true
|
|
1079
|
+
JOIN pg_catalog.pg_attribute a
|
|
1080
|
+
ON a.attrelid = con.conrelid
|
|
1081
|
+
AND a.attnum = k.attnum
|
|
1082
|
+
WHERE ns.nspname = $1
|
|
1083
|
+
AND con.contype = 'u'
|
|
1084
|
+
ORDER BY cl.relname, con.conname, k.ord`, [schema]);
|
|
1074
1085
|
const indexResult = await driver.query(`SELECT
|
|
1075
1086
|
i.tablename,
|
|
1076
1087
|
i.indexname,
|
|
@@ -1091,10 +1102,9 @@ var PostgresControlAdapter = class {
|
|
|
1091
1102
|
WHERE i.schemaname = $1
|
|
1092
1103
|
AND NOT EXISTS (
|
|
1093
1104
|
SELECT 1
|
|
1094
|
-
FROM
|
|
1095
|
-
WHERE
|
|
1096
|
-
AND
|
|
1097
|
-
AND tc.constraint_name = i.indexname
|
|
1105
|
+
FROM pg_catalog.pg_constraint con
|
|
1106
|
+
WHERE con.conindid = ic.oid
|
|
1107
|
+
AND con.contype IN ('p', 'u', 'x')
|
|
1098
1108
|
)
|
|
1099
1109
|
ORDER BY i.tablename, i.indexname, k.ord`, [schema]);
|
|
1100
1110
|
const checkResult = await driver.query(`SELECT
|
|
@@ -1154,7 +1164,8 @@ var PostgresControlAdapter = class {
|
|
|
1154
1164
|
const primaryKeyColumns = pkRows.sort((a, b) => a.ordinal_position - b.ordinal_position).map((row) => row.column_name);
|
|
1155
1165
|
const primaryKey = primaryKeyColumns.length > 0 ? {
|
|
1156
1166
|
columns: primaryKeyColumns,
|
|
1157
|
-
...pkRows[0]?.constraint_name ? { name: pkRows[0].constraint_name } : {}
|
|
1167
|
+
...pkRows[0]?.constraint_name ? { name: pkRows[0].constraint_name } : {},
|
|
1168
|
+
dependsOn: postgresColumnDependsOn(schema, tableName, primaryKeyColumns)
|
|
1158
1169
|
} : void 0;
|
|
1159
1170
|
const foreignKeysMap = /* @__PURE__ */ new Map();
|
|
1160
1171
|
for (const fkRow of fksByTable.get(tableName) ?? []) {
|
|
@@ -1179,7 +1190,8 @@ var PostgresControlAdapter = class {
|
|
|
1179
1190
|
referencedColumns: Object.freeze([...fk.referencedColumns]),
|
|
1180
1191
|
name: fk.name,
|
|
1181
1192
|
...ifDefined("onDelete", mapReferentialAction(fk.deleteRule)),
|
|
1182
|
-
...ifDefined("onUpdate", mapReferentialAction(fk.updateRule))
|
|
1193
|
+
...ifDefined("onUpdate", mapReferentialAction(fk.updateRule)),
|
|
1194
|
+
dependsOn: [postgresTableDependsOn(fk.referencedSchema, fk.referencedTable), ...postgresColumnDependsOn(schema, tableName, fk.columns)]
|
|
1183
1195
|
}));
|
|
1184
1196
|
const pkConstraints = pkConstraintsByTable.get(tableName) ?? /* @__PURE__ */ new Set();
|
|
1185
1197
|
const uniquesMap = /* @__PURE__ */ new Map();
|
|
@@ -1194,7 +1206,8 @@ var PostgresControlAdapter = class {
|
|
|
1194
1206
|
}
|
|
1195
1207
|
const uniques = Array.from(uniquesMap.values()).map((uq) => ({
|
|
1196
1208
|
columns: Object.freeze([...uq.columns]),
|
|
1197
|
-
name: uq.name
|
|
1209
|
+
name: uq.name,
|
|
1210
|
+
dependsOn: postgresColumnDependsOn(schema, tableName, uq.columns)
|
|
1198
1211
|
}));
|
|
1199
1212
|
const indexesMap = /* @__PURE__ */ new Map();
|
|
1200
1213
|
const indexNamesWithExpressionKey = /* @__PURE__ */ new Set();
|
|
@@ -1229,7 +1242,8 @@ var PostgresControlAdapter = class {
|
|
|
1229
1242
|
name: idx.name,
|
|
1230
1243
|
unique: idx.unique,
|
|
1231
1244
|
...idx.type !== void 0 && { type: idx.type },
|
|
1232
|
-
...idx.options !== void 0 && { options: idx.options }
|
|
1245
|
+
...idx.options !== void 0 && { options: idx.options },
|
|
1246
|
+
dependsOn: postgresColumnDependsOn(schema, tableName, idx.columns)
|
|
1233
1247
|
}));
|
|
1234
1248
|
const checksForTable = [];
|
|
1235
1249
|
for (const checkRow of checksByTable.get(tableName) ?? []) {
|
|
@@ -1281,7 +1295,8 @@ var PostgresControlAdapter = class {
|
|
|
1281
1295
|
roles: policyRoles,
|
|
1282
1296
|
...row.qual !== null ? { using: row.qual } : {},
|
|
1283
1297
|
...row.with_check !== null ? { withCheck: row.with_check } : {},
|
|
1284
|
-
permissive
|
|
1298
|
+
permissive,
|
|
1299
|
+
dependsOn: [postgresTableDependsOn(row.schemaname, row.tablename), ...policyRoles.map(postgresRoleDependsOn)]
|
|
1285
1300
|
});
|
|
1286
1301
|
const list = policiesByTable.get(row.tablename) ?? [];
|
|
1287
1302
|
list.push(policy);
|
|
@@ -1447,6 +1462,49 @@ function mapReferentialAction(rule) {
|
|
|
1447
1462
|
return mapped;
|
|
1448
1463
|
}
|
|
1449
1464
|
/**
|
|
1465
|
+
* A FK/policy dependency chain, mirroring the shape the expected-side
|
|
1466
|
+
* derivation stamps (`contractToPostgresDatabaseSchemaNode`): the database
|
|
1467
|
+
* root's fixed sentinel id, then the namespace, then the table.
|
|
1468
|
+
*/
|
|
1469
|
+
function postgresTableDependsOn(namespaceId, tableName) {
|
|
1470
|
+
return [
|
|
1471
|
+
{
|
|
1472
|
+
nodeKind: PostgresSchemaNodeKind.database,
|
|
1473
|
+
id: "database"
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
nodeKind: PostgresSchemaNodeKind.namespace,
|
|
1477
|
+
id: namespaceId
|
|
1478
|
+
},
|
|
1479
|
+
{
|
|
1480
|
+
nodeKind: PostgresSchemaNodeKind.table,
|
|
1481
|
+
id: tableName
|
|
1482
|
+
}
|
|
1483
|
+
];
|
|
1484
|
+
}
|
|
1485
|
+
/** A policy's dependency chain onto one of the roles it grants to. */
|
|
1486
|
+
function postgresRoleDependsOn(role) {
|
|
1487
|
+
return [{
|
|
1488
|
+
nodeKind: PostgresSchemaNodeKind.database,
|
|
1489
|
+
id: "database"
|
|
1490
|
+
}, {
|
|
1491
|
+
nodeKind: PostgresSchemaNodeKind.role,
|
|
1492
|
+
id: role
|
|
1493
|
+
}];
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* The chains from a table-child object (foreign key, index, unique, primary
|
|
1497
|
+
* key) to each of the own columns it is built on — the introspection-side
|
|
1498
|
+
* mirror of `contractToPostgresDatabaseSchemaNode`'s `columnDependsOn`. An
|
|
1499
|
+
* object is dropped before the columns it covers.
|
|
1500
|
+
*/
|
|
1501
|
+
function postgresColumnDependsOn(namespaceId, tableName, columns) {
|
|
1502
|
+
return columns.map((column) => [...postgresTableDependsOn(namespaceId, tableName), {
|
|
1503
|
+
nodeKind: RelationalSchemaNodeKind.column,
|
|
1504
|
+
id: `column:${column}`
|
|
1505
|
+
}]);
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1450
1508
|
* Groups an array of objects by a specified key.
|
|
1451
1509
|
* Returns a Map for O(1) lookup by group key.
|
|
1452
1510
|
*/
|
|
@@ -1727,4 +1785,4 @@ async function pgRenderDdlExecuteRequest(ast, codecLookup) {
|
|
|
1727
1785
|
//#endregion
|
|
1728
1786
|
export { renderLoweredSql as n, createPostgresBuiltinCodecLookup as r, PostgresControlAdapter as t };
|
|
1729
1787
|
|
|
1730
|
-
//# sourceMappingURL=control-adapter-
|
|
1788
|
+
//# sourceMappingURL=control-adapter-aFfSI2bK.mjs.map
|