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