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