@fragno-dev/db 0.1.13 → 0.1.15
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/.turbo/turbo-build.log +179 -132
- package/CHANGELOG.md +30 -0
- package/dist/adapters/adapters.d.ts +27 -1
- package/dist/adapters/adapters.d.ts.map +1 -1
- package/dist/adapters/adapters.js.map +1 -1
- package/dist/adapters/drizzle/drizzle-adapter.d.ts +5 -1
- package/dist/adapters/drizzle/drizzle-adapter.d.ts.map +1 -1
- package/dist/adapters/drizzle/drizzle-adapter.js +15 -3
- package/dist/adapters/drizzle/drizzle-adapter.js.map +1 -1
- package/dist/adapters/drizzle/drizzle-query.js +7 -5
- package/dist/adapters/drizzle/drizzle-query.js.map +1 -1
- package/dist/adapters/drizzle/drizzle-uow-compiler.d.ts +0 -1
- package/dist/adapters/drizzle/drizzle-uow-compiler.d.ts.map +1 -1
- package/dist/adapters/drizzle/drizzle-uow-compiler.js +76 -44
- package/dist/adapters/drizzle/drizzle-uow-compiler.js.map +1 -1
- package/dist/adapters/drizzle/drizzle-uow-decoder.js +23 -16
- package/dist/adapters/drizzle/drizzle-uow-decoder.js.map +1 -1
- package/dist/adapters/drizzle/drizzle-uow-executor.js +18 -7
- package/dist/adapters/drizzle/drizzle-uow-executor.js.map +1 -1
- package/dist/adapters/drizzle/generate.d.ts +4 -1
- package/dist/adapters/drizzle/generate.d.ts.map +1 -1
- package/dist/adapters/drizzle/generate.js +11 -18
- package/dist/adapters/drizzle/generate.js.map +1 -1
- package/dist/adapters/drizzle/shared.d.ts +14 -1
- package/dist/adapters/drizzle/shared.d.ts.map +1 -0
- package/dist/adapters/kysely/kysely-adapter.d.ts +5 -1
- package/dist/adapters/kysely/kysely-adapter.d.ts.map +1 -1
- package/dist/adapters/kysely/kysely-adapter.js +14 -3
- package/dist/adapters/kysely/kysely-adapter.js.map +1 -1
- package/dist/adapters/kysely/kysely-query-builder.js +1 -1
- package/dist/adapters/kysely/kysely-query-compiler.js +3 -2
- package/dist/adapters/kysely/kysely-query-compiler.js.map +1 -1
- package/dist/adapters/kysely/kysely-query.d.ts +1 -0
- package/dist/adapters/kysely/kysely-query.d.ts.map +1 -1
- package/dist/adapters/kysely/kysely-query.js +28 -19
- package/dist/adapters/kysely/kysely-query.js.map +1 -1
- package/dist/adapters/kysely/kysely-shared.d.ts +14 -0
- package/dist/adapters/kysely/kysely-shared.d.ts.map +1 -0
- package/dist/adapters/kysely/kysely-shared.js +16 -1
- package/dist/adapters/kysely/kysely-shared.js.map +1 -1
- package/dist/adapters/kysely/kysely-uow-compiler.js +68 -16
- package/dist/adapters/kysely/kysely-uow-compiler.js.map +1 -1
- package/dist/adapters/kysely/kysely-uow-executor.js +8 -4
- package/dist/adapters/kysely/kysely-uow-executor.js.map +1 -1
- package/dist/adapters/kysely/migration/execute-base.js +1 -1
- package/dist/adapters/kysely/migration/execute-base.js.map +1 -1
- package/dist/db-fragment-definition-builder.d.ts +152 -0
- package/dist/db-fragment-definition-builder.d.ts.map +1 -0
- package/dist/db-fragment-definition-builder.js +137 -0
- package/dist/db-fragment-definition-builder.js.map +1 -0
- package/dist/fragments/internal-fragment.d.ts +19 -0
- package/dist/fragments/internal-fragment.d.ts.map +1 -0
- package/dist/fragments/internal-fragment.js +39 -0
- package/dist/fragments/internal-fragment.js.map +1 -0
- package/dist/migration-engine/generation-engine.d.ts.map +1 -1
- package/dist/migration-engine/generation-engine.js +35 -15
- package/dist/migration-engine/generation-engine.js.map +1 -1
- package/dist/mod.d.ts +8 -18
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +7 -34
- package/dist/mod.js.map +1 -1
- package/dist/node_modules/.pnpm/rou3@0.7.8/node_modules/rou3/dist/index.js +165 -0
- package/dist/node_modules/.pnpm/rou3@0.7.8/node_modules/rou3/dist/index.js.map +1 -0
- package/dist/packages/fragno/dist/api/bind-services.js +20 -0
- package/dist/packages/fragno/dist/api/bind-services.js.map +1 -0
- package/dist/packages/fragno/dist/api/error.js +48 -0
- package/dist/packages/fragno/dist/api/error.js.map +1 -0
- package/dist/packages/fragno/dist/api/fragment-definition-builder.js +320 -0
- package/dist/packages/fragno/dist/api/fragment-definition-builder.js.map +1 -0
- package/dist/packages/fragno/dist/api/fragment-instantiator.js +487 -0
- package/dist/packages/fragno/dist/api/fragment-instantiator.js.map +1 -0
- package/dist/packages/fragno/dist/api/fragno-response.js +73 -0
- package/dist/packages/fragno/dist/api/fragno-response.js.map +1 -0
- package/dist/packages/fragno/dist/api/internal/response-stream.js +81 -0
- package/dist/packages/fragno/dist/api/internal/response-stream.js.map +1 -0
- package/dist/packages/fragno/dist/api/internal/route.js +10 -0
- package/dist/packages/fragno/dist/api/internal/route.js.map +1 -0
- package/dist/packages/fragno/dist/api/mutable-request-state.js +97 -0
- package/dist/packages/fragno/dist/api/mutable-request-state.js.map +1 -0
- package/dist/packages/fragno/dist/api/request-context-storage.js +43 -0
- package/dist/packages/fragno/dist/api/request-context-storage.js.map +1 -0
- package/dist/packages/fragno/dist/api/request-input-context.js +118 -0
- package/dist/packages/fragno/dist/api/request-input-context.js.map +1 -0
- package/dist/packages/fragno/dist/api/request-middleware.js +83 -0
- package/dist/packages/fragno/dist/api/request-middleware.js.map +1 -0
- package/dist/packages/fragno/dist/api/request-output-context.js +119 -0
- package/dist/packages/fragno/dist/api/request-output-context.js.map +1 -0
- package/dist/packages/fragno/dist/api/route.js +17 -0
- package/dist/packages/fragno/dist/api/route.js.map +1 -0
- package/dist/packages/fragno/dist/internal/symbols.js +10 -0
- package/dist/packages/fragno/dist/internal/symbols.js.map +1 -0
- package/dist/query/cursor.d.ts +10 -2
- package/dist/query/cursor.d.ts.map +1 -1
- package/dist/query/cursor.js +11 -4
- package/dist/query/cursor.js.map +1 -1
- package/dist/query/execute-unit-of-work.d.ts +123 -0
- package/dist/query/execute-unit-of-work.d.ts.map +1 -0
- package/dist/query/execute-unit-of-work.js +184 -0
- package/dist/query/execute-unit-of-work.js.map +1 -0
- package/dist/query/query.d.ts +3 -3
- package/dist/query/query.d.ts.map +1 -1
- package/dist/query/result-transform.js +4 -2
- package/dist/query/result-transform.js.map +1 -1
- package/dist/query/retry-policy.d.ts +88 -0
- package/dist/query/retry-policy.d.ts.map +1 -0
- package/dist/query/retry-policy.js +61 -0
- package/dist/query/retry-policy.js.map +1 -0
- package/dist/query/unit-of-work.d.ts +171 -32
- package/dist/query/unit-of-work.d.ts.map +1 -1
- package/dist/query/unit-of-work.js +530 -133
- package/dist/query/unit-of-work.js.map +1 -1
- package/dist/schema/serialize.js +12 -7
- package/dist/schema/serialize.js.map +1 -1
- package/dist/with-database.d.ts +28 -0
- package/dist/with-database.d.ts.map +1 -0
- package/dist/with-database.js +34 -0
- package/dist/with-database.js.map +1 -0
- package/package.json +10 -3
- package/src/adapters/adapters.ts +30 -0
- package/src/adapters/drizzle/drizzle-adapter-pglite.test.ts +86 -17
- package/src/adapters/drizzle/drizzle-adapter-sqlite.test.ts +291 -7
- package/src/adapters/drizzle/drizzle-adapter.test.ts +3 -51
- package/src/adapters/drizzle/drizzle-adapter.ts +35 -7
- package/src/adapters/drizzle/drizzle-query.ts +25 -15
- package/src/adapters/drizzle/drizzle-uow-compiler-mysql.test.ts +1442 -0
- package/src/adapters/drizzle/drizzle-uow-compiler-sqlite.test.ts +1414 -0
- package/src/adapters/drizzle/drizzle-uow-compiler.test.ts +78 -61
- package/src/adapters/drizzle/drizzle-uow-compiler.ts +123 -42
- package/src/adapters/drizzle/drizzle-uow-decoder.ts +34 -27
- package/src/adapters/drizzle/drizzle-uow-executor.ts +41 -8
- package/src/adapters/drizzle/generate.test.ts +102 -269
- package/src/adapters/drizzle/generate.ts +12 -30
- package/src/adapters/drizzle/test-utils.ts +36 -5
- package/src/adapters/kysely/kysely-adapter-pglite.test.ts +66 -22
- package/src/adapters/kysely/kysely-adapter-sqlite.test.ts +156 -0
- package/src/adapters/kysely/kysely-adapter.ts +25 -2
- package/src/adapters/kysely/kysely-query-compiler.ts +3 -8
- package/src/adapters/kysely/kysely-query.ts +57 -37
- package/src/adapters/kysely/kysely-shared.ts +34 -0
- package/src/adapters/kysely/kysely-uow-compiler.test.ts +62 -74
- package/src/adapters/kysely/kysely-uow-compiler.ts +92 -24
- package/src/adapters/kysely/kysely-uow-executor.ts +26 -7
- package/src/adapters/kysely/kysely-uow-joins.test.ts +33 -50
- package/src/adapters/kysely/migration/execute-base.ts +1 -1
- package/src/db-fragment-definition-builder.test.ts +887 -0
- package/src/db-fragment-definition-builder.ts +506 -0
- package/src/db-fragment-instantiator.test.ts +467 -0
- package/src/db-fragment-integration.test.ts +408 -0
- package/src/fragments/internal-fragment.test.ts +160 -0
- package/src/fragments/internal-fragment.ts +85 -0
- package/src/migration-engine/generation-engine.test.ts +58 -15
- package/src/migration-engine/generation-engine.ts +78 -25
- package/src/mod.ts +35 -43
- package/src/query/cursor.test.ts +119 -0
- package/src/query/cursor.ts +17 -4
- package/src/query/execute-unit-of-work.test.ts +1310 -0
- package/src/query/execute-unit-of-work.ts +463 -0
- package/src/query/query.ts +4 -4
- package/src/query/result-transform.test.ts +129 -0
- package/src/query/result-transform.ts +4 -1
- package/src/query/retry-policy.test.ts +217 -0
- package/src/query/retry-policy.ts +141 -0
- package/src/query/unit-of-work-coordinator.test.ts +833 -0
- package/src/query/unit-of-work-types.test.ts +15 -2
- package/src/query/unit-of-work.test.ts +878 -200
- package/src/query/unit-of-work.ts +963 -321
- package/src/schema/serialize.ts +22 -11
- package/src/with-database.ts +140 -0
- package/tsdown.config.ts +1 -0
- package/dist/fragment.d.ts +0 -54
- package/dist/fragment.d.ts.map +0 -1
- package/dist/fragment.js +0 -92
- package/dist/fragment.js.map +0 -1
- package/dist/shared/settings-schema.js +0 -36
- package/dist/shared/settings-schema.js.map +0 -1
- package/src/fragment.test.ts +0 -341
- package/src/fragment.ts +0 -198
- package/src/shared/settings-schema.ts +0 -61
|
@@ -9,13 +9,18 @@ function getAffectedRows(result: QueryResult<unknown>): number {
|
|
|
9
9
|
("affectedRows" in result &&
|
|
10
10
|
(typeof result["affectedRows"] === "number" || typeof result["affectedRows"] === "bigint")
|
|
11
11
|
? result["affectedRows"]
|
|
12
|
+
: undefined) ??
|
|
13
|
+
// SQLite via SQLocal returns `numUpdatedRows` as BigInt
|
|
14
|
+
("numUpdatedRows" in result &&
|
|
15
|
+
(typeof result["numUpdatedRows"] === "number" || typeof result["numUpdatedRows"] === "bigint")
|
|
16
|
+
? result["numUpdatedRows"]
|
|
12
17
|
: undefined);
|
|
13
18
|
|
|
14
19
|
if (affectedRows === undefined) {
|
|
15
|
-
throw new Error(
|
|
20
|
+
throw new Error(`No affected rows found: ${JSON.stringify(result)}`);
|
|
16
21
|
}
|
|
17
22
|
|
|
18
|
-
if (affectedRows > Number.MAX_SAFE_INTEGER) {
|
|
23
|
+
if (typeof affectedRows === "bigint" && affectedRows > Number.MAX_SAFE_INTEGER) {
|
|
19
24
|
throw new Error(
|
|
20
25
|
`affectedRows BigInt value ${affectedRows.toString()} exceeds JS safe integer range`,
|
|
21
26
|
);
|
|
@@ -100,23 +105,24 @@ export async function executeKyselyMutationPhase(
|
|
|
100
105
|
for (const compiledMutation of mutationBatch) {
|
|
101
106
|
const result = await tx.executeQuery(compiledMutation.query);
|
|
102
107
|
|
|
103
|
-
//
|
|
108
|
+
// Best-effort extraction: Try to get internal ID if available
|
|
109
|
+
// This is optional - the system works without it by using subqueries for references
|
|
104
110
|
if (compiledMutation.expectedAffectedRows === null) {
|
|
105
|
-
// Check if result has rows (RETURNING clause supported)
|
|
106
111
|
if (Array.isArray(result.rows) && result.rows.length > 0) {
|
|
107
112
|
const row = result.rows[0] as Record<string, unknown>;
|
|
108
113
|
if ("_internalId" in row || "_internal_id" in row) {
|
|
109
114
|
const internalId = (row["_internalId"] ?? row["_internal_id"]) as bigint;
|
|
110
115
|
createdInternalIds.push(internalId);
|
|
111
116
|
} else {
|
|
112
|
-
// RETURNING supported but _internalId not found
|
|
117
|
+
// RETURNING supported but _internalId not found - that's okay
|
|
113
118
|
createdInternalIds.push(null);
|
|
114
119
|
}
|
|
115
120
|
} else {
|
|
116
|
-
// No
|
|
121
|
+
// No rows returned (no RETURNING clause, or SQLite via executeQuery)
|
|
122
|
+
// This is fine - references will use subqueries based on external IDs
|
|
117
123
|
createdInternalIds.push(null);
|
|
118
124
|
}
|
|
119
|
-
} else {
|
|
125
|
+
} else if (compiledMutation.expectedAffectedRows !== null) {
|
|
120
126
|
// Check affected rows for updates/deletes
|
|
121
127
|
const affectedRows = getAffectedRows(result);
|
|
122
128
|
|
|
@@ -128,6 +134,19 @@ export async function executeKyselyMutationPhase(
|
|
|
128
134
|
);
|
|
129
135
|
}
|
|
130
136
|
}
|
|
137
|
+
|
|
138
|
+
if (compiledMutation.expectedReturnedRows !== null) {
|
|
139
|
+
// For SELECT queries (check operations), verify row count
|
|
140
|
+
const rowCount = Array.isArray(result.rows) ? result.rows.length : 0;
|
|
141
|
+
|
|
142
|
+
if (rowCount !== compiledMutation.expectedReturnedRows) {
|
|
143
|
+
// Version conflict detected - the SELECT didn't return the expected number of rows
|
|
144
|
+
// This means either the row doesn't exist or the version has changed
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Version conflict: expected ${compiledMutation.expectedReturnedRows} rows returned, but got ${rowCount}`,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
131
150
|
}
|
|
132
151
|
});
|
|
133
152
|
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { describe, it, beforeAll, assert, expect } from "vitest";
|
|
1
|
+
import { describe, it, assert, expect } from "vitest";
|
|
3
2
|
import { column, idColumn, referenceColumn, schema } from "../../schema/create";
|
|
4
|
-
import type { Kysely as KyselyType, PostgresDialectConfig } from "kysely";
|
|
5
3
|
import { UnitOfWork, type UOWDecoder } from "../../query/unit-of-work";
|
|
6
4
|
import { createKyselyUOWCompiler } from "./kysely-uow-compiler";
|
|
7
|
-
import type { ConnectionPool } from "../../shared/connection-pool";
|
|
8
|
-
import { createKyselyConnectionPool } from "./kysely-connection-pool";
|
|
9
5
|
|
|
10
6
|
describe("kysely-uow-joins", () => {
|
|
11
7
|
const userSchema = schema((s) => {
|
|
@@ -88,33 +84,20 @@ describe("kysely-uow-joins", () => {
|
|
|
88
84
|
);
|
|
89
85
|
});
|
|
90
86
|
|
|
91
|
-
let kysely: KyselyType<any>; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
|
-
let pool: ConnectionPool<Kysely<any>>;
|
|
94
|
-
|
|
95
|
-
beforeAll(async () => {
|
|
96
|
-
kysely = new Kysely({
|
|
97
|
-
dialect: new PostgresDialect({} as PostgresDialectConfig),
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Wrap in connection pool
|
|
101
|
-
pool = createKyselyConnectionPool(kysely);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
87
|
// Helper to create UnitOfWork for testing
|
|
105
88
|
function createTestUOW(name?: string) {
|
|
106
|
-
const mockCompiler = createKyselyUOWCompiler(
|
|
89
|
+
const mockCompiler = createKyselyUOWCompiler("postgresql");
|
|
107
90
|
const mockExecutor = {
|
|
108
91
|
executeRetrievalPhase: async () => [],
|
|
109
92
|
executeMutationPhase: async () => ({ success: true, createdInternalIds: [] }),
|
|
110
93
|
};
|
|
111
|
-
const mockDecoder: UOWDecoder
|
|
94
|
+
const mockDecoder: UOWDecoder = (rawResults, operations) => {
|
|
112
95
|
if (rawResults.length !== operations.length) {
|
|
113
96
|
throw new Error("rawResults and ops must have the same length");
|
|
114
97
|
}
|
|
115
98
|
return rawResults;
|
|
116
99
|
};
|
|
117
|
-
return new UnitOfWork(
|
|
100
|
+
return new UnitOfWork(mockCompiler, mockExecutor, mockDecoder, name).forSchema(userSchema);
|
|
118
101
|
}
|
|
119
102
|
|
|
120
103
|
describe("postgresql", () => {
|
|
@@ -127,7 +110,7 @@ describe("kysely-uow-joins", () => {
|
|
|
127
110
|
.join((jb) => jb.author()),
|
|
128
111
|
);
|
|
129
112
|
|
|
130
|
-
const compiler = createKyselyUOWCompiler(
|
|
113
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
131
114
|
const compiled = uow.compile(compiler);
|
|
132
115
|
|
|
133
116
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -147,7 +130,7 @@ describe("kysely-uow-joins", () => {
|
|
|
147
130
|
.join((jb) => jb.author((ab) => ab.select(["name", "email"]))),
|
|
148
131
|
);
|
|
149
132
|
|
|
150
|
-
const compiler = createKyselyUOWCompiler(
|
|
133
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
151
134
|
const compiled = uow.compile(compiler);
|
|
152
135
|
|
|
153
136
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -171,7 +154,7 @@ describe("kysely-uow-joins", () => {
|
|
|
171
154
|
),
|
|
172
155
|
);
|
|
173
156
|
|
|
174
|
-
const compiler = createKyselyUOWCompiler(
|
|
157
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
175
158
|
const compiled = uow.compile(compiler);
|
|
176
159
|
|
|
177
160
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -191,7 +174,7 @@ describe("kysely-uow-joins", () => {
|
|
|
191
174
|
.join((jb) => jb.inviter((ib) => ib.select(["name"]))),
|
|
192
175
|
);
|
|
193
176
|
|
|
194
|
-
const compiler = createKyselyUOWCompiler(
|
|
177
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
195
178
|
const compiled = uow.compile(compiler);
|
|
196
179
|
|
|
197
180
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -211,7 +194,7 @@ describe("kysely-uow-joins", () => {
|
|
|
211
194
|
.join((jb) => jb.post((pb) => pb.select(["title"])).author((ab) => ab.select(["name"]))),
|
|
212
195
|
);
|
|
213
196
|
|
|
214
|
-
const compiler = createKyselyUOWCompiler(
|
|
197
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
215
198
|
const compiled = uow.compile(compiler);
|
|
216
199
|
|
|
217
200
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -231,7 +214,7 @@ describe("kysely-uow-joins", () => {
|
|
|
231
214
|
.join((jb) => jb.post((pb) => pb.select(["title"])).tag((tb) => tb.select(["name"]))),
|
|
232
215
|
);
|
|
233
216
|
|
|
234
|
-
const compiler = createKyselyUOWCompiler(
|
|
217
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
235
218
|
const compiled = uow.compile(compiler);
|
|
236
219
|
|
|
237
220
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -261,7 +244,7 @@ describe("kysely-uow-joins", () => {
|
|
|
261
244
|
),
|
|
262
245
|
);
|
|
263
246
|
|
|
264
|
-
const compiler = createKyselyUOWCompiler(
|
|
247
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
265
248
|
const compiled = uow.compile(compiler);
|
|
266
249
|
|
|
267
250
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -281,7 +264,7 @@ describe("kysely-uow-joins", () => {
|
|
|
281
264
|
.join((jb) => jb.author((ab) => ab.select(["name"]).orderByIndex("idx_name", "asc"))),
|
|
282
265
|
);
|
|
283
266
|
|
|
284
|
-
const compiler = createKyselyUOWCompiler(
|
|
267
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
285
268
|
const compiled = uow.compile(compiler);
|
|
286
269
|
|
|
287
270
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -302,7 +285,7 @@ describe("kysely-uow-joins", () => {
|
|
|
302
285
|
.join((jb) => jb.author((ab) => ab.select(["name"]).pageSize(1))),
|
|
303
286
|
);
|
|
304
287
|
|
|
305
|
-
const compiler = createKyselyUOWCompiler(
|
|
288
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
306
289
|
const compiled = uow.compile(compiler);
|
|
307
290
|
|
|
308
291
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -330,7 +313,7 @@ describe("kysely-uow-joins", () => {
|
|
|
330
313
|
),
|
|
331
314
|
);
|
|
332
315
|
|
|
333
|
-
const compiler = createKyselyUOWCompiler(
|
|
316
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
334
317
|
const compiled = uow.compile(compiler);
|
|
335
318
|
|
|
336
319
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -353,7 +336,7 @@ describe("kysely-uow-joins", () => {
|
|
|
353
336
|
.join((jb) => jb.author((ab) => ab.select(["id", "name"]))),
|
|
354
337
|
);
|
|
355
338
|
|
|
356
|
-
const compiler = createKyselyUOWCompiler(
|
|
339
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
357
340
|
const compiled = uow.compile(compiler);
|
|
358
341
|
|
|
359
342
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -376,7 +359,7 @@ describe("kysely-uow-joins", () => {
|
|
|
376
359
|
.join((jb) => jb.author((ab) => ab.select(["id", "name"]))),
|
|
377
360
|
);
|
|
378
361
|
|
|
379
|
-
const compiler = createKyselyUOWCompiler(
|
|
362
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
380
363
|
const compiled = uow.compile(compiler);
|
|
381
364
|
|
|
382
365
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -401,7 +384,7 @@ describe("kysely-uow-joins", () => {
|
|
|
401
384
|
.join((jb) => jb.author((ab) => ab.select(["id"]))),
|
|
402
385
|
);
|
|
403
386
|
|
|
404
|
-
const compiler = createKyselyUOWCompiler(
|
|
387
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
405
388
|
const compiled = uow.compile(compiler);
|
|
406
389
|
|
|
407
390
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -423,7 +406,7 @@ describe("kysely-uow-joins", () => {
|
|
|
423
406
|
.join((jb) => jb.author((ab) => ab.select(["id", "name"]))),
|
|
424
407
|
);
|
|
425
408
|
|
|
426
|
-
const compiler = createKyselyUOWCompiler(
|
|
409
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
427
410
|
const compiled = uow.compile(compiler);
|
|
428
411
|
|
|
429
412
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -446,7 +429,7 @@ describe("kysely-uow-joins", () => {
|
|
|
446
429
|
.join((jb) => jb.author((ab) => ab.select(["name"]))),
|
|
447
430
|
);
|
|
448
431
|
|
|
449
|
-
const compiler = createKyselyUOWCompiler(
|
|
432
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
450
433
|
const compiled = uow.compile(compiler);
|
|
451
434
|
|
|
452
435
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -466,7 +449,7 @@ describe("kysely-uow-joins", () => {
|
|
|
466
449
|
const uow = createTestUOW();
|
|
467
450
|
uow.find("posts", (b) => b.whereIndex("primary").join((jb) => jb.author()));
|
|
468
451
|
|
|
469
|
-
const compiler = createKyselyUOWCompiler(
|
|
452
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
470
453
|
const compiled = uow.compile(compiler);
|
|
471
454
|
|
|
472
455
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -494,7 +477,7 @@ describe("kysely-uow-joins", () => {
|
|
|
494
477
|
),
|
|
495
478
|
);
|
|
496
479
|
|
|
497
|
-
const compiler = createKyselyUOWCompiler(
|
|
480
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
498
481
|
const compiled = uow.compile(compiler);
|
|
499
482
|
|
|
500
483
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -517,7 +500,7 @@ describe("kysely-uow-joins", () => {
|
|
|
517
500
|
),
|
|
518
501
|
);
|
|
519
502
|
|
|
520
|
-
const compiler = createKyselyUOWCompiler(
|
|
503
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
521
504
|
const compiled = uow.compile(compiler);
|
|
522
505
|
|
|
523
506
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -575,18 +558,18 @@ describe("kysely-uow-joins", () => {
|
|
|
575
558
|
});
|
|
576
559
|
|
|
577
560
|
function createCustomIdTestUOW() {
|
|
578
|
-
const mockCompiler = createKyselyUOWCompiler(
|
|
561
|
+
const mockCompiler = createKyselyUOWCompiler("postgresql");
|
|
579
562
|
const mockExecutor = {
|
|
580
563
|
executeRetrievalPhase: async () => [],
|
|
581
564
|
executeMutationPhase: async () => ({ success: true, createdInternalIds: [] }),
|
|
582
565
|
};
|
|
583
|
-
const mockDecoder: UOWDecoder
|
|
566
|
+
const mockDecoder: UOWDecoder = (rawResults, operations) => {
|
|
584
567
|
if (rawResults.length !== operations.length) {
|
|
585
568
|
throw new Error("rawResults and ops must have the same length");
|
|
586
569
|
}
|
|
587
570
|
return rawResults;
|
|
588
571
|
};
|
|
589
|
-
return new UnitOfWork(
|
|
572
|
+
return new UnitOfWork(mockCompiler, mockExecutor, mockDecoder).forSchema(customIdSchema);
|
|
590
573
|
}
|
|
591
574
|
|
|
592
575
|
it("should compile join with custom id column names", () => {
|
|
@@ -602,7 +585,7 @@ describe("kysely-uow-joins", () => {
|
|
|
602
585
|
),
|
|
603
586
|
);
|
|
604
587
|
|
|
605
|
-
const compiler = createKyselyUOWCompiler(
|
|
588
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
606
589
|
const compiled = uow.compile(compiler);
|
|
607
590
|
|
|
608
591
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -636,7 +619,7 @@ describe("kysely-uow-joins", () => {
|
|
|
636
619
|
),
|
|
637
620
|
);
|
|
638
621
|
|
|
639
|
-
const compiler = createKyselyUOWCompiler(
|
|
622
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
640
623
|
const compiled = uow.compile(compiler);
|
|
641
624
|
|
|
642
625
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -655,7 +638,7 @@ describe("kysely-uow-joins", () => {
|
|
|
655
638
|
const uow = createCustomIdTestUOW();
|
|
656
639
|
uow.find("product_categories", (b) => b.whereIndex("primary").join((jb) => jb.product()));
|
|
657
640
|
|
|
658
|
-
const compiler = createKyselyUOWCompiler(
|
|
641
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
659
642
|
const compiled = uow.compile(compiler);
|
|
660
643
|
|
|
661
644
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -685,7 +668,7 @@ describe("kysely-uow-joins", () => {
|
|
|
685
668
|
),
|
|
686
669
|
);
|
|
687
670
|
|
|
688
|
-
const compiler = createKyselyUOWCompiler(
|
|
671
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
689
672
|
const compiled = uow.compile(compiler);
|
|
690
673
|
|
|
691
674
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -717,7 +700,7 @@ describe("kysely-uow-joins", () => {
|
|
|
717
700
|
.join((jb) => jb.author((ab) => ab.select(["id"]))),
|
|
718
701
|
);
|
|
719
702
|
|
|
720
|
-
const compiler = createKyselyUOWCompiler(
|
|
703
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
721
704
|
const compiled = uow.compile(compiler);
|
|
722
705
|
|
|
723
706
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -741,7 +724,7 @@ describe("kysely-uow-joins", () => {
|
|
|
741
724
|
.join((jb) => jb.author((ab) => ab.select(["id", "name"]))),
|
|
742
725
|
);
|
|
743
726
|
|
|
744
|
-
const compiler = createKyselyUOWCompiler(
|
|
727
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
745
728
|
const compiled = uow.compile(compiler);
|
|
746
729
|
|
|
747
730
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -765,7 +748,7 @@ describe("kysely-uow-joins", () => {
|
|
|
765
748
|
.join((jb) => jb.post((pb) => pb.select(["id"])).author((ab) => ab.select(["id"]))),
|
|
766
749
|
);
|
|
767
750
|
|
|
768
|
-
const compiler = createKyselyUOWCompiler(
|
|
751
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
769
752
|
const compiled = uow.compile(compiler);
|
|
770
753
|
|
|
771
754
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -793,7 +776,7 @@ describe("kysely-uow-joins", () => {
|
|
|
793
776
|
.join((jb) => jb.inviter((ib) => ib.select(["id", "name"]))),
|
|
794
777
|
);
|
|
795
778
|
|
|
796
|
-
const compiler = createKyselyUOWCompiler(
|
|
779
|
+
const compiler = createKyselyUOWCompiler("postgresql");
|
|
797
780
|
const compiled = uow.compile(compiler);
|
|
798
781
|
|
|
799
782
|
expect(compiled.retrievalBatch).toHaveLength(1);
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
import type { SQLProvider } from "../../../shared/providers";
|
|
8
8
|
import { schemaToDBType } from "../../../schema/serialize";
|
|
9
9
|
import type { TableNameMapper } from "../kysely-shared";
|
|
10
|
-
import { SETTINGS_TABLE_NAME } from "../../../
|
|
10
|
+
import { SETTINGS_TABLE_NAME } from "../../../fragments/internal-fragment";
|
|
11
11
|
|
|
12
12
|
export type ExecuteNode = {
|
|
13
13
|
compile(): { sql: string; parameters: readonly unknown[] };
|