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.
@@ -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.7",
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(params) {
7318
+ function createDatabaseExecutor(options) {
7338
7319
  return __async(this, null, function* () {
7339
- const { databaseUrl, dialect } = params;
7320
+ const { databaseUrl, dialect, connectTimeoutMs = 3e4 } = options;
7340
7321
  if (dialect === "postgres") {
7341
7322
  const postgres = yield import('postgres');
7342
- cleanDatabaseUrl(databaseUrl);
7343
- const sql = postgres.default(databaseUrl, { max: 1 });
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: (sqlStr, params2) => __async(null, null, function* () {
7347
- return yield sql.unsafe(sqlStr, params2 || []);
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(`Dialect ${dialect} not supported for stats collection`);
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 Promise.race([
7935
- createDatabaseExecutor({
7936
- databaseUrl: datasourceUrl,
7937
- dialect: config.dialect
7938
- }),
7939
- timeoutHandle
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:",