prisma-sql 1.75.7 → 1.75.8
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/collect-planner-stats.cjs +8 -25
- package/dist/collect-planner-stats.cjs.map +1 -1
- package/dist/collect-planner-stats.js +8 -25
- package/dist/collect-planner-stats.js.map +1 -1
- package/dist/generator.cjs +18 -52
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +18 -52
- package/dist/generator.js.map +1 -1
- package/package.json +1 -1
package/dist/generator.js
CHANGED
|
@@ -68,7 +68,7 @@ var require_package = __commonJS({
|
|
|
68
68
|
"package.json"(exports$1, module) {
|
|
69
69
|
module.exports = {
|
|
70
70
|
name: "prisma-sql",
|
|
71
|
-
version: "1.75.
|
|
71
|
+
version: "1.75.8",
|
|
72
72
|
description: "Convert Prisma queries to optimized SQL with type safety. 2-7x faster than Prisma Client.",
|
|
73
73
|
main: "dist/index.cjs",
|
|
74
74
|
module: "dist/index.js",
|
|
@@ -7287,25 +7287,6 @@ function stableJson(value) {
|
|
|
7287
7287
|
2
|
|
7288
7288
|
);
|
|
7289
7289
|
}
|
|
7290
|
-
function cleanDatabaseUrl(url) {
|
|
7291
|
-
try {
|
|
7292
|
-
const parsed = new URL(url);
|
|
7293
|
-
parsed.search = "";
|
|
7294
|
-
if (parsed.password) {
|
|
7295
|
-
parsed.password = "***";
|
|
7296
|
-
}
|
|
7297
|
-
if (parsed.username && parsed.username.length > 0) {
|
|
7298
|
-
if (parsed.username.length <= 3) {
|
|
7299
|
-
parsed.username = "***";
|
|
7300
|
-
} else {
|
|
7301
|
-
parsed.username = parsed.username.slice(0, 3) + "***";
|
|
7302
|
-
}
|
|
7303
|
-
}
|
|
7304
|
-
return parsed.toString();
|
|
7305
|
-
} catch (error) {
|
|
7306
|
-
return "[invalid-url]";
|
|
7307
|
-
}
|
|
7308
|
-
}
|
|
7309
7290
|
function createQueryKey(processedQuery) {
|
|
7310
7291
|
return JSON.stringify(processedQuery, (key, value) => {
|
|
7311
7292
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
@@ -7332,17 +7313,19 @@ function countTotalQueries(queries) {
|
|
|
7332
7313
|
function quoteIdent(dialect, ident) {
|
|
7333
7314
|
return `"${ident.replace(/"/g, '""')}"`;
|
|
7334
7315
|
}
|
|
7335
|
-
function createDatabaseExecutor(
|
|
7316
|
+
function createDatabaseExecutor(options) {
|
|
7336
7317
|
return __async(this, null, function* () {
|
|
7337
|
-
const { databaseUrl, dialect } =
|
|
7318
|
+
const { databaseUrl, dialect, connectTimeoutMs = 3e4 } = options;
|
|
7338
7319
|
if (dialect === "postgres") {
|
|
7339
7320
|
const postgres = yield import('postgres');
|
|
7340
|
-
|
|
7341
|
-
|
|
7321
|
+
const sql = postgres.default(databaseUrl, {
|
|
7322
|
+
connect_timeout: Math.ceil(connectTimeoutMs / 1e3),
|
|
7323
|
+
max: 1
|
|
7324
|
+
});
|
|
7342
7325
|
return {
|
|
7343
7326
|
executor: {
|
|
7344
|
-
query: (
|
|
7345
|
-
return yield sql.unsafe(
|
|
7327
|
+
query: (q, params) => __async(null, null, function* () {
|
|
7328
|
+
return yield sql.unsafe(q, params != null ? params : []);
|
|
7346
7329
|
})
|
|
7347
7330
|
},
|
|
7348
7331
|
cleanup: () => __async(null, null, function* () {
|
|
@@ -7350,7 +7333,7 @@ function createDatabaseExecutor(params) {
|
|
|
7350
7333
|
})
|
|
7351
7334
|
};
|
|
7352
7335
|
}
|
|
7353
|
-
throw new Error(`
|
|
7336
|
+
throw new Error(`createDatabaseExecutor does not support dialect: ${dialect}`);
|
|
7354
7337
|
});
|
|
7355
7338
|
}
|
|
7356
7339
|
function extractMeasurableOneToManyEdges(datamodel) {
|
|
@@ -7821,6 +7804,7 @@ function emitPlannerGeneratedModule(artifacts) {
|
|
|
7821
7804
|
}
|
|
7822
7805
|
|
|
7823
7806
|
// src/code-emitter.ts
|
|
7807
|
+
var DB_CONNECT_TIMEOUT_MS = 5e3;
|
|
7824
7808
|
function extractEnumMappings(datamodel) {
|
|
7825
7809
|
const mappings = {};
|
|
7826
7810
|
const fieldTypes = {};
|
|
@@ -7891,7 +7875,6 @@ function processAllModelDirectives(directiveResults, config) {
|
|
|
7891
7875
|
}
|
|
7892
7876
|
return { queries, skippedCount };
|
|
7893
7877
|
}
|
|
7894
|
-
var DB_CONNECT_TIMEOUT_MS = 5e3;
|
|
7895
7878
|
function generateClient(options) {
|
|
7896
7879
|
return __async(this, null, function* () {
|
|
7897
7880
|
var _a3;
|
|
@@ -7915,31 +7898,14 @@ function generateClient(options) {
|
|
|
7915
7898
|
let executor = options.executor;
|
|
7916
7899
|
let cleanup;
|
|
7917
7900
|
if (!executor && datasourceUrl) {
|
|
7918
|
-
let timedOut = false;
|
|
7919
|
-
const timeoutHandle = new Promise((_, reject) => {
|
|
7920
|
-
var _a4;
|
|
7921
|
-
const id = setTimeout(() => {
|
|
7922
|
-
timedOut = true;
|
|
7923
|
-
reject(
|
|
7924
|
-
new Error(
|
|
7925
|
-
`DB connection timed out after ${DB_CONNECT_TIMEOUT_MS}ms`
|
|
7926
|
-
)
|
|
7927
|
-
);
|
|
7928
|
-
}, DB_CONNECT_TIMEOUT_MS);
|
|
7929
|
-
(_a4 = id.unref) == null ? void 0 : _a4.call(id);
|
|
7930
|
-
});
|
|
7931
7901
|
try {
|
|
7932
|
-
const dbConn = yield
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
if (!timedOut) {
|
|
7940
|
-
executor = dbConn.executor;
|
|
7941
|
-
cleanup = dbConn.cleanup;
|
|
7942
|
-
}
|
|
7902
|
+
const dbConn = yield createDatabaseExecutor({
|
|
7903
|
+
databaseUrl: datasourceUrl,
|
|
7904
|
+
dialect: config.dialect,
|
|
7905
|
+
connectTimeoutMs: DB_CONNECT_TIMEOUT_MS
|
|
7906
|
+
});
|
|
7907
|
+
executor = dbConn.executor;
|
|
7908
|
+
cleanup = dbConn.cleanup;
|
|
7943
7909
|
} catch (error) {
|
|
7944
7910
|
console.warn(
|
|
7945
7911
|
"\u26A0 Failed to connect:",
|