@prisma/client-engine-runtime 6.14.0-dev.35 → 6.14.0-dev.37
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/batch.d.ts +19 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +311 -244
- package/dist/index.mjs +309 -244
- package/dist/interpreter/{DataMapper.d.ts → data-mapper.d.ts} +1 -1
- package/dist/interpreter/in-memory-processing.d.ts +1 -1
- package/dist/interpreter/{QueryInterpreter.d.ts → query-interpreter.d.ts} +2 -2
- package/dist/interpreter/{renderQuery.d.ts → render-query.d.ts} +1 -1
- package/dist/interpreter/validation.d.ts +1 -1
- package/dist/json-protocol.d.ts +5 -0
- package/dist/{transactionManager/TransactionManagerErrors.d.ts → transaction-manager/transaction-manager-error.d.ts} +1 -1
- package/dist/{transactionManager/TransactionManager.d.ts → transaction-manager/transaction-manager.d.ts} +1 -1
- package/dist/transaction-manager/transaction-manager.test.d.ts +1 -0
- package/package.json +3 -3
- /package/dist/interpreter/{renderQuery.test.d.ts → render-query.test.d.ts} +0 -0
- /package/dist/interpreter/{serializeSql.d.ts → serialize-sql.d.ts} +0 -0
- /package/dist/interpreter/{serializeSql.test.d.ts → serialize-sql.test.d.ts} +0 -0
- /package/dist/{transactionManager/TransactionManager.test.d.ts → json-protocol.test.d.ts} +0 -0
- /package/dist/{QueryPlan.d.ts → query-plan.d.ts} +0 -0
- /package/dist/{transactionManager/Transaction.d.ts → transaction-manager/transaction.d.ts} +0 -0
- /package/dist/{UserFacingError.d.ts → user-facing-error.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -35,6 +35,8 @@ __export(index_exports, {
|
|
|
35
35
|
TransactionManager: () => TransactionManager,
|
|
36
36
|
TransactionManagerError: () => TransactionManagerError,
|
|
37
37
|
UserFacingError: () => UserFacingError,
|
|
38
|
+
convertCompactedRows: () => convertCompactedRows,
|
|
39
|
+
deserializeJsonResponse: () => deserializeJsonResponse,
|
|
38
40
|
doKeysMatch: () => doKeysMatch,
|
|
39
41
|
isDeepStrictEqual: () => isDeepStrictEqual,
|
|
40
42
|
isPrismaValueBigInt: () => isPrismaValueBigInt,
|
|
@@ -48,8 +50,8 @@ __export(index_exports, {
|
|
|
48
50
|
});
|
|
49
51
|
module.exports = __toCommonJS(index_exports);
|
|
50
52
|
|
|
51
|
-
// src/
|
|
52
|
-
var import_decimal2 =
|
|
53
|
+
// src/json-protocol.ts
|
|
54
|
+
var import_decimal2 = require("decimal.js");
|
|
53
55
|
|
|
54
56
|
// src/utils.ts
|
|
55
57
|
var import_decimal = __toESM(require("decimal.js"));
|
|
@@ -143,7 +145,303 @@ function safeJsonStringify(obj) {
|
|
|
143
145
|
});
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
// src/
|
|
148
|
+
// src/json-protocol.ts
|
|
149
|
+
function normalizeJsonProtocolValues(result) {
|
|
150
|
+
if (result === null) {
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
if (Array.isArray(result)) {
|
|
154
|
+
return result.map(normalizeJsonProtocolValues);
|
|
155
|
+
}
|
|
156
|
+
if (typeof result === "object") {
|
|
157
|
+
if (isTaggedValue(result)) {
|
|
158
|
+
return normalizeTaggedValue(result);
|
|
159
|
+
}
|
|
160
|
+
if (result.constructor !== null && result.constructor.name !== "Object") {
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
return mapObjectValues(result, normalizeJsonProtocolValues);
|
|
164
|
+
}
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
function isTaggedValue(value) {
|
|
168
|
+
return value !== null && typeof value == "object" && typeof value["$type"] === "string";
|
|
169
|
+
}
|
|
170
|
+
function normalizeTaggedValue({ $type, value }) {
|
|
171
|
+
switch ($type) {
|
|
172
|
+
case "BigInt":
|
|
173
|
+
return { $type, value: String(value) };
|
|
174
|
+
case "Bytes":
|
|
175
|
+
return { $type, value };
|
|
176
|
+
case "DateTime":
|
|
177
|
+
return { $type, value: new Date(value).toISOString() };
|
|
178
|
+
case "Decimal":
|
|
179
|
+
return { $type, value: String(new import_decimal2.Decimal(value)) };
|
|
180
|
+
case "Json":
|
|
181
|
+
return { $type, value: JSON.stringify(JSON.parse(value)) };
|
|
182
|
+
default:
|
|
183
|
+
assertNever(value, "Unknown tagged value");
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function mapObjectValues(object, mapper) {
|
|
187
|
+
const result = {};
|
|
188
|
+
for (const key of Object.keys(object)) {
|
|
189
|
+
result[key] = mapper(object[key], key);
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
function deserializeJsonResponse(result) {
|
|
194
|
+
if (result === null) {
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
if (Array.isArray(result)) {
|
|
198
|
+
return result.map(deserializeJsonResponse);
|
|
199
|
+
}
|
|
200
|
+
if (typeof result === "object") {
|
|
201
|
+
if (isTaggedValue(result)) {
|
|
202
|
+
return deserializeTaggedValue(result);
|
|
203
|
+
}
|
|
204
|
+
if (result.constructor !== null && result.constructor.name !== "Object") {
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
return mapObjectValues(result, deserializeJsonResponse);
|
|
208
|
+
}
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
function deserializeTaggedValue({ $type, value }) {
|
|
212
|
+
switch ($type) {
|
|
213
|
+
case "BigInt":
|
|
214
|
+
return BigInt(value);
|
|
215
|
+
case "Bytes": {
|
|
216
|
+
const { buffer, byteOffset, byteLength } = Buffer.from(value, "base64");
|
|
217
|
+
return new Uint8Array(buffer, byteOffset, byteLength);
|
|
218
|
+
}
|
|
219
|
+
case "DateTime":
|
|
220
|
+
return new Date(value);
|
|
221
|
+
case "Decimal":
|
|
222
|
+
return new import_decimal2.Decimal(value);
|
|
223
|
+
case "Json":
|
|
224
|
+
return JSON.parse(value);
|
|
225
|
+
default:
|
|
226
|
+
assertNever(value, "Unknown tagged value");
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/user-facing-error.ts
|
|
231
|
+
var import_driver_adapter_utils = require("@prisma/driver-adapter-utils");
|
|
232
|
+
var UserFacingError = class extends Error {
|
|
233
|
+
name = "UserFacingError";
|
|
234
|
+
code;
|
|
235
|
+
meta;
|
|
236
|
+
constructor(message, code, meta) {
|
|
237
|
+
super(message);
|
|
238
|
+
this.code = code;
|
|
239
|
+
this.meta = meta ?? {};
|
|
240
|
+
}
|
|
241
|
+
toQueryResponseErrorObject() {
|
|
242
|
+
return {
|
|
243
|
+
error: this.message,
|
|
244
|
+
user_facing_error: {
|
|
245
|
+
is_panic: false,
|
|
246
|
+
message: this.message,
|
|
247
|
+
meta: this.meta,
|
|
248
|
+
error_code: this.code
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
function rethrowAsUserFacing(error) {
|
|
254
|
+
if (!(0, import_driver_adapter_utils.isDriverAdapterError)(error)) {
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
const code = getErrorCode(error);
|
|
258
|
+
const message = renderErrorMessage(error);
|
|
259
|
+
if (!code || !message) {
|
|
260
|
+
throw error;
|
|
261
|
+
}
|
|
262
|
+
throw new UserFacingError(message, code, { driverAdapterError: error });
|
|
263
|
+
}
|
|
264
|
+
function rethrowAsUserFacingRawError(error) {
|
|
265
|
+
if (!(0, import_driver_adapter_utils.isDriverAdapterError)(error)) {
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
268
|
+
throw new UserFacingError(
|
|
269
|
+
`Raw query failed. Code: \`${error.cause.originalCode ?? "N/A"}\`. Message: \`${error.cause.originalMessage ?? renderErrorMessage(error)}\``,
|
|
270
|
+
"P2010",
|
|
271
|
+
{ driverAdapterError: error }
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
function getErrorCode(err) {
|
|
275
|
+
switch (err.cause.kind) {
|
|
276
|
+
case "AuthenticationFailed":
|
|
277
|
+
return "P1000";
|
|
278
|
+
case "DatabaseNotReachable":
|
|
279
|
+
return "P1001";
|
|
280
|
+
case "DatabaseDoesNotExist":
|
|
281
|
+
return "P1003";
|
|
282
|
+
case "SocketTimeout":
|
|
283
|
+
return "P1008";
|
|
284
|
+
case "DatabaseAlreadyExists":
|
|
285
|
+
return "P1009";
|
|
286
|
+
case "DatabaseAccessDenied":
|
|
287
|
+
return "P1010";
|
|
288
|
+
case "TlsConnectionError":
|
|
289
|
+
return "P1011";
|
|
290
|
+
case "ConnectionClosed":
|
|
291
|
+
return "P1017";
|
|
292
|
+
case "TransactionAlreadyClosed":
|
|
293
|
+
return "P1018";
|
|
294
|
+
case "LengthMismatch":
|
|
295
|
+
return "P2000";
|
|
296
|
+
case "UniqueConstraintViolation":
|
|
297
|
+
return "P2002";
|
|
298
|
+
case "ForeignKeyConstraintViolation":
|
|
299
|
+
return "P2003";
|
|
300
|
+
case "UnsupportedNativeDataType":
|
|
301
|
+
return "P2010";
|
|
302
|
+
case "NullConstraintViolation":
|
|
303
|
+
return "P2011";
|
|
304
|
+
case "ValueOutOfRange":
|
|
305
|
+
return "P2020";
|
|
306
|
+
case "TableDoesNotExist":
|
|
307
|
+
return "P2021";
|
|
308
|
+
case "ColumnNotFound":
|
|
309
|
+
return "P2022";
|
|
310
|
+
case "InvalidIsolationLevel":
|
|
311
|
+
case "InconsistentColumnData":
|
|
312
|
+
return "P2023";
|
|
313
|
+
case "MissingFullTextSearchIndex":
|
|
314
|
+
return "P2030";
|
|
315
|
+
case "TransactionWriteConflict":
|
|
316
|
+
return "P2034";
|
|
317
|
+
case "GenericJs":
|
|
318
|
+
return "P2036";
|
|
319
|
+
case "TooManyConnections":
|
|
320
|
+
return "P2037";
|
|
321
|
+
case "postgres":
|
|
322
|
+
case "sqlite":
|
|
323
|
+
case "mysql":
|
|
324
|
+
case "mssql":
|
|
325
|
+
return;
|
|
326
|
+
default:
|
|
327
|
+
assertNever(err.cause, `Unknown error: ${err.cause}`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function renderErrorMessage(err) {
|
|
331
|
+
switch (err.cause.kind) {
|
|
332
|
+
case "AuthenticationFailed": {
|
|
333
|
+
const user = err.cause.user ?? "(not available)";
|
|
334
|
+
return `Authentication failed against the database server, the provided database credentials for \`${user}\` are not valid`;
|
|
335
|
+
}
|
|
336
|
+
case "DatabaseNotReachable": {
|
|
337
|
+
const address = err.cause.host && err.cause.port ? `${err.cause.host}:${err.cause.port}` : err.cause.host;
|
|
338
|
+
return `Can't reach database server${address ? ` at ${address}` : ""}`;
|
|
339
|
+
}
|
|
340
|
+
case "DatabaseDoesNotExist": {
|
|
341
|
+
const db = err.cause.db ?? "(not available)";
|
|
342
|
+
return `Database \`${db}\` does not exist on the database server`;
|
|
343
|
+
}
|
|
344
|
+
case "SocketTimeout":
|
|
345
|
+
return `Operation has timed out`;
|
|
346
|
+
case "DatabaseAlreadyExists": {
|
|
347
|
+
const db = err.cause.db ?? "(not available)";
|
|
348
|
+
return `Database \`${db}\` already exists on the database server`;
|
|
349
|
+
}
|
|
350
|
+
case "DatabaseAccessDenied": {
|
|
351
|
+
const db = err.cause.db ?? "(not available)";
|
|
352
|
+
return `User was denied access on the database \`${db}\``;
|
|
353
|
+
}
|
|
354
|
+
case "TlsConnectionError": {
|
|
355
|
+
return `Error opening a TLS connection: ${err.cause.reason}`;
|
|
356
|
+
}
|
|
357
|
+
case "ConnectionClosed": {
|
|
358
|
+
return "Server has closed the connection.";
|
|
359
|
+
}
|
|
360
|
+
case "TransactionAlreadyClosed":
|
|
361
|
+
return err.cause.cause;
|
|
362
|
+
case "LengthMismatch": {
|
|
363
|
+
const column = err.cause.column ?? "(not available)";
|
|
364
|
+
return `The provided value for the column is too long for the column's type. Column: ${column}`;
|
|
365
|
+
}
|
|
366
|
+
case "UniqueConstraintViolation":
|
|
367
|
+
return `Unique constraint failed on the ${renderConstraint(err.cause.constraint)}`;
|
|
368
|
+
case "ForeignKeyConstraintViolation":
|
|
369
|
+
return `Foreign key constraint violated on the ${renderConstraint(err.cause.constraint)}`;
|
|
370
|
+
case "UnsupportedNativeDataType":
|
|
371
|
+
return `Failed to deserialize column of type '${err.cause.type}'. If you're using $queryRaw and this column is explicitly marked as \`Unsupported\` in your Prisma schema, try casting this column to any supported Prisma type such as \`String\`.`;
|
|
372
|
+
case "NullConstraintViolation":
|
|
373
|
+
return `Null constraint violation on the ${renderConstraint(err.cause.constraint)}`;
|
|
374
|
+
case "ValueOutOfRange":
|
|
375
|
+
return `Value out of range for the type: ${err.cause.cause}`;
|
|
376
|
+
case "TableDoesNotExist": {
|
|
377
|
+
const table = err.cause.table ?? "(not available)";
|
|
378
|
+
return `The table \`${table}\` does not exist in the current database.`;
|
|
379
|
+
}
|
|
380
|
+
case "ColumnNotFound": {
|
|
381
|
+
const column = err.cause.column ?? "(not available)";
|
|
382
|
+
return `The column \`${column}\` does not exist in the current database.`;
|
|
383
|
+
}
|
|
384
|
+
case "InvalidIsolationLevel":
|
|
385
|
+
return `Error in connector: Conversion error: ${err.cause.level}`;
|
|
386
|
+
case "InconsistentColumnData":
|
|
387
|
+
return `Inconsistent column data: ${err.cause.cause}`;
|
|
388
|
+
case "MissingFullTextSearchIndex":
|
|
389
|
+
return "Cannot find a fulltext index to use for the native search, try adding a @@fulltext([Fields...]) to your schema";
|
|
390
|
+
case "TransactionWriteConflict":
|
|
391
|
+
return `Transaction failed due to a write conflict or a deadlock. Please retry your transaction`;
|
|
392
|
+
case "GenericJs":
|
|
393
|
+
return `Error in external connector (id ${err.cause.id})`;
|
|
394
|
+
case "TooManyConnections":
|
|
395
|
+
return `Too many database connections opened: ${err.cause.cause}`;
|
|
396
|
+
case "sqlite":
|
|
397
|
+
case "postgres":
|
|
398
|
+
case "mysql":
|
|
399
|
+
case "mssql":
|
|
400
|
+
return;
|
|
401
|
+
default:
|
|
402
|
+
assertNever(err.cause, `Unknown error: ${err.cause}`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function renderConstraint(constraint) {
|
|
406
|
+
if (constraint && "fields" in constraint) {
|
|
407
|
+
return `fields: (${constraint.fields.map((field) => `\`${field}\``).join(", ")})`;
|
|
408
|
+
} else if (constraint && "index" in constraint) {
|
|
409
|
+
return `constraint: \`${constraint.index}\``;
|
|
410
|
+
} else if (constraint && "foreignKey" in constraint) {
|
|
411
|
+
return `foreign key`;
|
|
412
|
+
}
|
|
413
|
+
return "(not available)";
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// src/batch.ts
|
|
417
|
+
function convertCompactedRows(rows, compiledBatch) {
|
|
418
|
+
const keysPerRow = rows.map(
|
|
419
|
+
(item) => compiledBatch.keys.reduce((acc, key) => {
|
|
420
|
+
acc[key] = deserializeJsonResponse(item[key]);
|
|
421
|
+
return acc;
|
|
422
|
+
}, {})
|
|
423
|
+
);
|
|
424
|
+
const selection = new Set(compiledBatch.nestedSelection);
|
|
425
|
+
return compiledBatch.arguments.map((args) => {
|
|
426
|
+
const rowIndex = keysPerRow.findIndex((rowKeys) => doKeysMatch(rowKeys, args));
|
|
427
|
+
if (rowIndex === -1) {
|
|
428
|
+
if (compiledBatch.expectNonEmpty) {
|
|
429
|
+
return new UserFacingError(
|
|
430
|
+
"An operation failed because it depends on one or more records that were required but not found",
|
|
431
|
+
"P2025"
|
|
432
|
+
);
|
|
433
|
+
} else {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
} else {
|
|
437
|
+
const selected = Object.entries(rows[rowIndex]).filter(([k]) => selection.has(k));
|
|
438
|
+
return Object.fromEntries(selected);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// src/interpreter/data-mapper.ts
|
|
444
|
+
var import_decimal3 = __toESM(require("decimal.js"));
|
|
147
445
|
var DataMapperError = class extends Error {
|
|
148
446
|
name = "DataMapperError";
|
|
149
447
|
};
|
|
@@ -298,7 +596,7 @@ function mapValue(value, columnName, resultType, enums) {
|
|
|
298
596
|
throw new DataMapperError(`Expected a boolean in column '${columnName}', got ${typeof value}: ${value}`);
|
|
299
597
|
}
|
|
300
598
|
case "Decimal":
|
|
301
|
-
if (typeof value !== "number" && typeof value !== "string" && !
|
|
599
|
+
if (typeof value !== "number" && typeof value !== "string" && !import_decimal3.default.isDecimal(value)) {
|
|
302
600
|
throw new DataMapperError(`Expected a decimal in column '${columnName}', got ${typeof value}: ${value}`);
|
|
303
601
|
}
|
|
304
602
|
return { $type: "Decimal", value };
|
|
@@ -422,192 +720,6 @@ async function withQuerySpanAndEvent({
|
|
|
422
720
|
);
|
|
423
721
|
}
|
|
424
722
|
|
|
425
|
-
// src/UserFacingError.ts
|
|
426
|
-
var import_driver_adapter_utils = require("@prisma/driver-adapter-utils");
|
|
427
|
-
var UserFacingError = class extends Error {
|
|
428
|
-
name = "UserFacingError";
|
|
429
|
-
code;
|
|
430
|
-
meta;
|
|
431
|
-
constructor(message, code, meta) {
|
|
432
|
-
super(message);
|
|
433
|
-
this.code = code;
|
|
434
|
-
this.meta = meta ?? {};
|
|
435
|
-
}
|
|
436
|
-
toQueryResponseErrorObject() {
|
|
437
|
-
return {
|
|
438
|
-
error: this.message,
|
|
439
|
-
user_facing_error: {
|
|
440
|
-
is_panic: false,
|
|
441
|
-
message: this.message,
|
|
442
|
-
meta: this.meta,
|
|
443
|
-
error_code: this.code
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
};
|
|
448
|
-
function rethrowAsUserFacing(error) {
|
|
449
|
-
if (!(0, import_driver_adapter_utils.isDriverAdapterError)(error)) {
|
|
450
|
-
throw error;
|
|
451
|
-
}
|
|
452
|
-
const code = getErrorCode(error);
|
|
453
|
-
const message = renderErrorMessage(error);
|
|
454
|
-
if (!code || !message) {
|
|
455
|
-
throw error;
|
|
456
|
-
}
|
|
457
|
-
throw new UserFacingError(message, code, { driverAdapterError: error });
|
|
458
|
-
}
|
|
459
|
-
function rethrowAsUserFacingRawError(error) {
|
|
460
|
-
if (!(0, import_driver_adapter_utils.isDriverAdapterError)(error)) {
|
|
461
|
-
throw error;
|
|
462
|
-
}
|
|
463
|
-
throw new UserFacingError(
|
|
464
|
-
`Raw query failed. Code: \`${error.cause.originalCode ?? "N/A"}\`. Message: \`${error.cause.originalMessage ?? renderErrorMessage(error)}\``,
|
|
465
|
-
"P2010",
|
|
466
|
-
{ driverAdapterError: error }
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
function getErrorCode(err) {
|
|
470
|
-
switch (err.cause.kind) {
|
|
471
|
-
case "AuthenticationFailed":
|
|
472
|
-
return "P1000";
|
|
473
|
-
case "DatabaseNotReachable":
|
|
474
|
-
return "P1001";
|
|
475
|
-
case "DatabaseDoesNotExist":
|
|
476
|
-
return "P1003";
|
|
477
|
-
case "SocketTimeout":
|
|
478
|
-
return "P1008";
|
|
479
|
-
case "DatabaseAlreadyExists":
|
|
480
|
-
return "P1009";
|
|
481
|
-
case "DatabaseAccessDenied":
|
|
482
|
-
return "P1010";
|
|
483
|
-
case "TlsConnectionError":
|
|
484
|
-
return "P1011";
|
|
485
|
-
case "ConnectionClosed":
|
|
486
|
-
return "P1017";
|
|
487
|
-
case "TransactionAlreadyClosed":
|
|
488
|
-
return "P1018";
|
|
489
|
-
case "LengthMismatch":
|
|
490
|
-
return "P2000";
|
|
491
|
-
case "UniqueConstraintViolation":
|
|
492
|
-
return "P2002";
|
|
493
|
-
case "ForeignKeyConstraintViolation":
|
|
494
|
-
return "P2003";
|
|
495
|
-
case "UnsupportedNativeDataType":
|
|
496
|
-
return "P2010";
|
|
497
|
-
case "NullConstraintViolation":
|
|
498
|
-
return "P2011";
|
|
499
|
-
case "ValueOutOfRange":
|
|
500
|
-
return "P2020";
|
|
501
|
-
case "TableDoesNotExist":
|
|
502
|
-
return "P2021";
|
|
503
|
-
case "ColumnNotFound":
|
|
504
|
-
return "P2022";
|
|
505
|
-
case "InvalidIsolationLevel":
|
|
506
|
-
case "InconsistentColumnData":
|
|
507
|
-
return "P2023";
|
|
508
|
-
case "MissingFullTextSearchIndex":
|
|
509
|
-
return "P2030";
|
|
510
|
-
case "TransactionWriteConflict":
|
|
511
|
-
return "P2034";
|
|
512
|
-
case "GenericJs":
|
|
513
|
-
return "P2036";
|
|
514
|
-
case "TooManyConnections":
|
|
515
|
-
return "P2037";
|
|
516
|
-
case "postgres":
|
|
517
|
-
case "sqlite":
|
|
518
|
-
case "mysql":
|
|
519
|
-
case "mssql":
|
|
520
|
-
return;
|
|
521
|
-
default:
|
|
522
|
-
assertNever(err.cause, `Unknown error: ${err.cause}`);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
function renderErrorMessage(err) {
|
|
526
|
-
switch (err.cause.kind) {
|
|
527
|
-
case "AuthenticationFailed": {
|
|
528
|
-
const user = err.cause.user ?? "(not available)";
|
|
529
|
-
return `Authentication failed against the database server, the provided database credentials for \`${user}\` are not valid`;
|
|
530
|
-
}
|
|
531
|
-
case "DatabaseNotReachable": {
|
|
532
|
-
const address = err.cause.host && err.cause.port ? `${err.cause.host}:${err.cause.port}` : err.cause.host;
|
|
533
|
-
return `Can't reach database server${address ? ` at ${address}` : ""}`;
|
|
534
|
-
}
|
|
535
|
-
case "DatabaseDoesNotExist": {
|
|
536
|
-
const db = err.cause.db ?? "(not available)";
|
|
537
|
-
return `Database \`${db}\` does not exist on the database server`;
|
|
538
|
-
}
|
|
539
|
-
case "SocketTimeout":
|
|
540
|
-
return `Operation has timed out`;
|
|
541
|
-
case "DatabaseAlreadyExists": {
|
|
542
|
-
const db = err.cause.db ?? "(not available)";
|
|
543
|
-
return `Database \`${db}\` already exists on the database server`;
|
|
544
|
-
}
|
|
545
|
-
case "DatabaseAccessDenied": {
|
|
546
|
-
const db = err.cause.db ?? "(not available)";
|
|
547
|
-
return `User was denied access on the database \`${db}\``;
|
|
548
|
-
}
|
|
549
|
-
case "TlsConnectionError": {
|
|
550
|
-
return `Error opening a TLS connection: ${err.cause.reason}`;
|
|
551
|
-
}
|
|
552
|
-
case "ConnectionClosed": {
|
|
553
|
-
return "Server has closed the connection.";
|
|
554
|
-
}
|
|
555
|
-
case "TransactionAlreadyClosed":
|
|
556
|
-
return err.cause.cause;
|
|
557
|
-
case "LengthMismatch": {
|
|
558
|
-
const column = err.cause.column ?? "(not available)";
|
|
559
|
-
return `The provided value for the column is too long for the column's type. Column: ${column}`;
|
|
560
|
-
}
|
|
561
|
-
case "UniqueConstraintViolation":
|
|
562
|
-
return `Unique constraint failed on the ${renderConstraint(err.cause.constraint)}`;
|
|
563
|
-
case "ForeignKeyConstraintViolation":
|
|
564
|
-
return `Foreign key constraint violated on the ${renderConstraint(err.cause.constraint)}`;
|
|
565
|
-
case "UnsupportedNativeDataType":
|
|
566
|
-
return `Failed to deserialize column of type '${err.cause.type}'. If you're using $queryRaw and this column is explicitly marked as \`Unsupported\` in your Prisma schema, try casting this column to any supported Prisma type such as \`String\`.`;
|
|
567
|
-
case "NullConstraintViolation":
|
|
568
|
-
return `Null constraint violation on the ${renderConstraint(err.cause.constraint)}`;
|
|
569
|
-
case "ValueOutOfRange":
|
|
570
|
-
return `Value out of range for the type: ${err.cause.cause}`;
|
|
571
|
-
case "TableDoesNotExist": {
|
|
572
|
-
const table = err.cause.table ?? "(not available)";
|
|
573
|
-
return `The table \`${table}\` does not exist in the current database.`;
|
|
574
|
-
}
|
|
575
|
-
case "ColumnNotFound": {
|
|
576
|
-
const column = err.cause.column ?? "(not available)";
|
|
577
|
-
return `The column \`${column}\` does not exist in the current database.`;
|
|
578
|
-
}
|
|
579
|
-
case "InvalidIsolationLevel":
|
|
580
|
-
return `Error in connector: Conversion error: ${err.cause.level}`;
|
|
581
|
-
case "InconsistentColumnData":
|
|
582
|
-
return `Inconsistent column data: ${err.cause.cause}`;
|
|
583
|
-
case "MissingFullTextSearchIndex":
|
|
584
|
-
return "Cannot find a fulltext index to use for the native search, try adding a @@fulltext([Fields...]) to your schema";
|
|
585
|
-
case "TransactionWriteConflict":
|
|
586
|
-
return `Transaction failed due to a write conflict or a deadlock. Please retry your transaction`;
|
|
587
|
-
case "GenericJs":
|
|
588
|
-
return `Error in external connector (id ${err.cause.id})`;
|
|
589
|
-
case "TooManyConnections":
|
|
590
|
-
return `Too many database connections opened: ${err.cause.cause}`;
|
|
591
|
-
case "sqlite":
|
|
592
|
-
case "postgres":
|
|
593
|
-
case "mysql":
|
|
594
|
-
case "mssql":
|
|
595
|
-
return;
|
|
596
|
-
default:
|
|
597
|
-
assertNever(err.cause, `Unknown error: ${err.cause}`);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
function renderConstraint(constraint) {
|
|
601
|
-
if (constraint && "fields" in constraint) {
|
|
602
|
-
return `fields: (${constraint.fields.map((field) => `\`${field}\``).join(", ")})`;
|
|
603
|
-
} else if (constraint && "index" in constraint) {
|
|
604
|
-
return `constraint: \`${constraint.index}\``;
|
|
605
|
-
} else if (constraint && "foreignKey" in constraint) {
|
|
606
|
-
return `foreign key`;
|
|
607
|
-
}
|
|
608
|
-
return "(not available)";
|
|
609
|
-
}
|
|
610
|
-
|
|
611
723
|
// src/interpreter/generators.ts
|
|
612
724
|
var import_cuid = __toESM(require("@bugsnag/cuid"));
|
|
613
725
|
var import_cuid2 = require("@paralleldrive/cuid2");
|
|
@@ -800,7 +912,7 @@ function getRecordKey(record, fields) {
|
|
|
800
912
|
return JSON.stringify(fields.map((field) => record[field]));
|
|
801
913
|
}
|
|
802
914
|
|
|
803
|
-
// src/
|
|
915
|
+
// src/query-plan.ts
|
|
804
916
|
function isPrismaValuePlaceholder(value) {
|
|
805
917
|
return typeof value === "object" && value !== null && value["prisma__type"] === "param";
|
|
806
918
|
}
|
|
@@ -814,7 +926,7 @@ function isPrismaValueBigInt(value) {
|
|
|
814
926
|
return typeof value === "object" && value !== null && value["prisma__type"] === "bigint";
|
|
815
927
|
}
|
|
816
928
|
|
|
817
|
-
// src/interpreter/
|
|
929
|
+
// src/interpreter/render-query.ts
|
|
818
930
|
function renderQuery(dbQuery, scope, generators, maxChunkSize) {
|
|
819
931
|
const queryType = dbQuery.type;
|
|
820
932
|
const params = evaluateParams(dbQuery.params, scope, generators);
|
|
@@ -1067,7 +1179,7 @@ function chunkArray(array, chunkSize) {
|
|
|
1067
1179
|
return result;
|
|
1068
1180
|
}
|
|
1069
1181
|
|
|
1070
|
-
// src/interpreter/
|
|
1182
|
+
// src/interpreter/serialize-sql.ts
|
|
1071
1183
|
var import_driver_adapter_utils2 = require("@prisma/driver-adapter-utils");
|
|
1072
1184
|
function serializeSql(resultSet) {
|
|
1073
1185
|
const mappers = resultSet.columnTypes.map((type) => {
|
|
@@ -1326,7 +1438,7 @@ function getErrorCode2(error) {
|
|
|
1326
1438
|
}
|
|
1327
1439
|
}
|
|
1328
1440
|
|
|
1329
|
-
// src/interpreter/
|
|
1441
|
+
// src/interpreter/query-interpreter.ts
|
|
1330
1442
|
var QueryInterpreter = class _QueryInterpreter {
|
|
1331
1443
|
#transactionManager;
|
|
1332
1444
|
#placeholderValues;
|
|
@@ -1704,53 +1816,6 @@ function evalFieldOperation(op, value, scope, generators) {
|
|
|
1704
1816
|
}
|
|
1705
1817
|
}
|
|
1706
1818
|
|
|
1707
|
-
// src/json-protocol.ts
|
|
1708
|
-
var import_decimal3 = require("decimal.js");
|
|
1709
|
-
function normalizeJsonProtocolValues(result) {
|
|
1710
|
-
if (result === null) {
|
|
1711
|
-
return result;
|
|
1712
|
-
}
|
|
1713
|
-
if (Array.isArray(result)) {
|
|
1714
|
-
return result.map(normalizeJsonProtocolValues);
|
|
1715
|
-
}
|
|
1716
|
-
if (typeof result === "object") {
|
|
1717
|
-
if (isTaggedValue(result)) {
|
|
1718
|
-
return normalizeTaggedValue(result);
|
|
1719
|
-
}
|
|
1720
|
-
if (result.constructor !== null && result.constructor.name !== "Object") {
|
|
1721
|
-
return result;
|
|
1722
|
-
}
|
|
1723
|
-
return mapObjectValues(result, normalizeJsonProtocolValues);
|
|
1724
|
-
}
|
|
1725
|
-
return result;
|
|
1726
|
-
}
|
|
1727
|
-
function isTaggedValue(value) {
|
|
1728
|
-
return value !== null && typeof value == "object" && typeof value["$type"] === "string";
|
|
1729
|
-
}
|
|
1730
|
-
function normalizeTaggedValue({ $type, value }) {
|
|
1731
|
-
switch ($type) {
|
|
1732
|
-
case "BigInt":
|
|
1733
|
-
return { $type, value: String(value) };
|
|
1734
|
-
case "Bytes":
|
|
1735
|
-
return { $type, value };
|
|
1736
|
-
case "DateTime":
|
|
1737
|
-
return { $type, value: new Date(value).toISOString() };
|
|
1738
|
-
case "Decimal":
|
|
1739
|
-
return { $type, value: String(new import_decimal3.Decimal(value)) };
|
|
1740
|
-
case "Json":
|
|
1741
|
-
return { $type, value: JSON.stringify(JSON.parse(value)) };
|
|
1742
|
-
default:
|
|
1743
|
-
assertNever(value, "Unknown tagged value");
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
function mapObjectValues(object, mapper) {
|
|
1747
|
-
const result = {};
|
|
1748
|
-
for (const key of Object.keys(object)) {
|
|
1749
|
-
result[key] = mapper(object[key], key);
|
|
1750
|
-
}
|
|
1751
|
-
return result;
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
1819
|
// src/raw-json-protocol.ts
|
|
1755
1820
|
var import_decimal4 = __toESM(require("decimal.js"));
|
|
1756
1821
|
function normalizeRawJsonProtocolResponse(response) {
|
|
@@ -1780,7 +1845,7 @@ function normalizeValue(type, value) {
|
|
|
1780
1845
|
}
|
|
1781
1846
|
}
|
|
1782
1847
|
|
|
1783
|
-
// src/
|
|
1848
|
+
// src/transaction-manager/transaction-manager.ts
|
|
1784
1849
|
var import_debug = require("@prisma/debug");
|
|
1785
1850
|
|
|
1786
1851
|
// src/crypto.ts
|
|
@@ -1792,7 +1857,7 @@ async function randomUUID() {
|
|
|
1792
1857
|
return crypto.randomUUID();
|
|
1793
1858
|
}
|
|
1794
1859
|
|
|
1795
|
-
// src/
|
|
1860
|
+
// src/transaction-manager/transaction-manager-error.ts
|
|
1796
1861
|
var TransactionManagerError = class extends UserFacingError {
|
|
1797
1862
|
name = "TransactionManagerError";
|
|
1798
1863
|
constructor(message, meta) {
|
|
@@ -1845,7 +1910,7 @@ var InvalidTransactionIsolationLevelError = class extends TransactionManagerErro
|
|
|
1845
1910
|
}
|
|
1846
1911
|
};
|
|
1847
1912
|
|
|
1848
|
-
// src/
|
|
1913
|
+
// src/transaction-manager/transaction-manager.ts
|
|
1849
1914
|
var MAX_CLOSED_TRANSACTIONS = 100;
|
|
1850
1915
|
var debug = (0, import_debug.Debug)("prisma:client:transactionManager");
|
|
1851
1916
|
var COMMIT_QUERY = () => ({ sql: "COMMIT", args: [], argTypes: [] });
|
|
@@ -2048,6 +2113,8 @@ var TransactionManager = class {
|
|
|
2048
2113
|
TransactionManager,
|
|
2049
2114
|
TransactionManagerError,
|
|
2050
2115
|
UserFacingError,
|
|
2116
|
+
convertCompactedRows,
|
|
2117
|
+
deserializeJsonResponse,
|
|
2051
2118
|
doKeysMatch,
|
|
2052
2119
|
isDeepStrictEqual,
|
|
2053
2120
|
isPrismaValueBigInt,
|