prisma-sql 1.75.8 → 1.75.9
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 +7 -0
- package/dist/collect-planner-stats.cjs.map +1 -1
- package/dist/collect-planner-stats.js +7 -0
- package/dist/collect-planner-stats.js.map +1 -1
- package/dist/generator.cjs +67 -39
- package/dist/generator.cjs.map +1 -1
- package/dist/generator.js +67 -39
- 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.9",
|
|
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",
|
|
@@ -7895,44 +7895,17 @@ function generateClient(options) {
|
|
|
7895
7895
|
yield mkdir(absoluteOutputDir, { recursive: true });
|
|
7896
7896
|
let plannerArtifacts = options.plannerArtifacts;
|
|
7897
7897
|
if (!plannerArtifacts) {
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
} catch (error) {
|
|
7910
|
-
console.warn(
|
|
7911
|
-
"\u26A0 Failed to connect:",
|
|
7912
|
-
error instanceof Error ? error.message : error
|
|
7913
|
-
);
|
|
7914
|
-
}
|
|
7915
|
-
}
|
|
7916
|
-
if (executor) {
|
|
7917
|
-
try {
|
|
7918
|
-
console.log(
|
|
7919
|
-
"\u{1F4CA} Collecting relation cardinalities and roundtrip cost..."
|
|
7920
|
-
);
|
|
7921
|
-
plannerArtifacts = yield collectPlannerArtifacts({
|
|
7922
|
-
executor,
|
|
7923
|
-
datamodel,
|
|
7924
|
-
dialect: config.dialect
|
|
7925
|
-
});
|
|
7926
|
-
} catch (error) {
|
|
7927
|
-
console.warn(
|
|
7928
|
-
"\u26A0 Failed to collect stats:",
|
|
7929
|
-
error instanceof Error ? error.message : error
|
|
7930
|
-
);
|
|
7931
|
-
} finally {
|
|
7932
|
-
if (cleanup) {
|
|
7933
|
-
yield cleanup();
|
|
7934
|
-
}
|
|
7935
|
-
}
|
|
7898
|
+
const skipPlanner = process.env.PRISMA_SQL_SKIP_PLANNER === "1" || process.env.PRISMA_SQL_SKIP_PLANNER === "true";
|
|
7899
|
+
if (skipPlanner) {
|
|
7900
|
+
console.log(
|
|
7901
|
+
"\u23ED Skipping planner stats collection (PRISMA_SQL_SKIP_PLANNER)"
|
|
7902
|
+
);
|
|
7903
|
+
} else {
|
|
7904
|
+
plannerArtifacts = yield collectPlannerWithTimeout(
|
|
7905
|
+
options,
|
|
7906
|
+
config,
|
|
7907
|
+
datasourceUrl
|
|
7908
|
+
);
|
|
7936
7909
|
}
|
|
7937
7910
|
}
|
|
7938
7911
|
if (!plannerArtifacts) {
|
|
@@ -7964,6 +7937,61 @@ function generateClient(options) {
|
|
|
7964
7937
|
console.log(`\u2713 Output: ${outputPath}`);
|
|
7965
7938
|
});
|
|
7966
7939
|
}
|
|
7940
|
+
var PLANNER_TOTAL_TIMEOUT_MS = 15e3;
|
|
7941
|
+
function collectPlannerWithTimeout(options, config, datasourceUrl) {
|
|
7942
|
+
return __async(this, null, function* () {
|
|
7943
|
+
const timeoutMs = Number(process.env.PRISMA_SQL_PLANNER_TIMEOUT_MS) || PLANNER_TOTAL_TIMEOUT_MS;
|
|
7944
|
+
let cleanup;
|
|
7945
|
+
let settled = false;
|
|
7946
|
+
const work = () => __async(null, null, function* () {
|
|
7947
|
+
let executor = options.executor;
|
|
7948
|
+
if (!executor && datasourceUrl) {
|
|
7949
|
+
const dbConn = yield createDatabaseExecutor({
|
|
7950
|
+
databaseUrl: datasourceUrl,
|
|
7951
|
+
dialect: config.dialect,
|
|
7952
|
+
connectTimeoutMs: DB_CONNECT_TIMEOUT_MS
|
|
7953
|
+
});
|
|
7954
|
+
executor = dbConn.executor;
|
|
7955
|
+
cleanup = dbConn.cleanup;
|
|
7956
|
+
}
|
|
7957
|
+
if (!executor) return void 0;
|
|
7958
|
+
console.log("\u{1F4CA} Collecting relation cardinalities and roundtrip cost...");
|
|
7959
|
+
return yield collectPlannerArtifacts({
|
|
7960
|
+
executor,
|
|
7961
|
+
datamodel: options.datamodel,
|
|
7962
|
+
dialect: config.dialect
|
|
7963
|
+
});
|
|
7964
|
+
});
|
|
7965
|
+
const timeout = new Promise((resolve3) => {
|
|
7966
|
+
const id = setTimeout(() => {
|
|
7967
|
+
settled = true;
|
|
7968
|
+
console.warn(
|
|
7969
|
+
`\u26A0 Planner stats collection timed out after ${timeoutMs}ms, using defaults`
|
|
7970
|
+
);
|
|
7971
|
+
resolve3(void 0);
|
|
7972
|
+
}, timeoutMs);
|
|
7973
|
+
if (typeof id === "object" && "unref" in id) id.unref();
|
|
7974
|
+
});
|
|
7975
|
+
try {
|
|
7976
|
+
const result = yield Promise.race([work(), timeout]);
|
|
7977
|
+
if (settled) return void 0;
|
|
7978
|
+
return result;
|
|
7979
|
+
} catch (error) {
|
|
7980
|
+
if (!settled) {
|
|
7981
|
+
console.warn(
|
|
7982
|
+
"\u26A0 Failed to collect planner stats:",
|
|
7983
|
+
error instanceof Error ? error.message : error
|
|
7984
|
+
);
|
|
7985
|
+
}
|
|
7986
|
+
return void 0;
|
|
7987
|
+
} finally {
|
|
7988
|
+
if (cleanup) {
|
|
7989
|
+
yield cleanup().catch(() => {
|
|
7990
|
+
});
|
|
7991
|
+
}
|
|
7992
|
+
}
|
|
7993
|
+
});
|
|
7994
|
+
}
|
|
7967
7995
|
function generateImports(runtimeImportPath) {
|
|
7968
7996
|
return `import {
|
|
7969
7997
|
buildSQL,
|