drizzle-kit 1.0.0-beta.2-31baa2b → 1.0.0-beta.2-f9236e3

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/api-mysql.mjs CHANGED
@@ -17336,8 +17336,7 @@ var init_schemaValidator = __esm({
17336
17336
  "singlestore",
17337
17337
  "gel",
17338
17338
  "mssql",
17339
- "cockroach",
17340
- "duckdb"
17339
+ "cockroach"
17341
17340
  ];
17342
17341
  dialect3 = enumType(dialects);
17343
17342
  }
@@ -28730,7 +28729,7 @@ var require_websocket = __commonJS({
28730
28729
  var EventEmitter = __require("events");
28731
28730
  var https2 = __require("https");
28732
28731
  var http3 = __require("http");
28733
- var net = __require("net");
28732
+ var net2 = __require("net");
28734
28733
  var tls = __require("tls");
28735
28734
  var { randomBytes, createHash: createHash5 } = __require("crypto");
28736
28735
  var { Duplex, Readable: Readable6 } = __require("stream");
@@ -29461,12 +29460,12 @@ var require_websocket = __commonJS({
29461
29460
  }
29462
29461
  function netConnect(options) {
29463
29462
  options.path = options.socketPath;
29464
- return net.connect(options);
29463
+ return net2.connect(options);
29465
29464
  }
29466
29465
  function tlsConnect(options) {
29467
29466
  options.path = void 0;
29468
29467
  if (!options.servername && options.servername !== "") {
29469
- options.servername = net.isIP(options.host) ? "" : options.host;
29468
+ options.servername = net2.isIP(options.host) ? "" : options.host;
29470
29469
  }
29471
29470
  return tls.connect(options);
29472
29471
  }
@@ -33784,7 +33783,7 @@ var init_timing = __esm({
33784
33783
  "../node_modules/.pnpm/@smithy+node-http-handler@4.4.5/node_modules/@smithy/node-http-handler/dist-es/timing.js"() {
33785
33784
  "use strict";
33786
33785
  timing = {
33787
- setTimeout: (cb, ms) => setTimeout(cb, ms),
33786
+ setTimeout: (cb, ms2) => setTimeout(cb, ms2),
33788
33787
  clearTimeout: (timeoutId) => clearTimeout(timeoutId)
33789
33788
  };
33790
33789
  }
@@ -35672,13 +35671,13 @@ var init_schema_date_utils = __esm({
35672
35671
  if (!matches) {
35673
35672
  throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
35674
35673
  }
35675
- const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms, offsetStr] = matches;
35674
+ const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms2, offsetStr] = matches;
35676
35675
  range(monthStr, 1, 12);
35677
35676
  range(dayStr, 1, 31);
35678
35677
  range(hours, 0, 23);
35679
35678
  range(minutes, 0, 59);
35680
35679
  range(seconds, 0, 60);
35681
- const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(ms) ? Math.round(parseFloat(`0.${ms}`) * 1e3) : 0));
35680
+ const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(ms2) ? Math.round(parseFloat(`0.${ms2}`) * 1e3) : 0));
35682
35681
  date2.setUTCFullYear(Number(yearStr));
35683
35682
  if (offsetStr.toUpperCase() != "Z") {
35684
35683
  const [, sign2, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
@@ -55691,8 +55690,8 @@ var require_datetime2 = __commonJS({
55691
55690
  if (!(object instanceof Date)) {
55692
55691
  throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
55693
55692
  }
55694
- const ms = object.getTime() - TIMESHIFT;
55695
- const us = ms * 1e3;
55693
+ const ms2 = object.getTime() - TIMESHIFT;
55694
+ const us = ms2 * 1e3;
55696
55695
  buf.writeInt32(8);
55697
55696
  buf.writeInt64(us);
55698
55697
  }
@@ -55702,12 +55701,12 @@ var require_datetime2 = __commonJS({
55702
55701
  return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
55703
55702
  }
55704
55703
  const us = Number(buf.readBigInt64());
55705
- let ms = Math.round(us / 1e3);
55706
- if (Math.abs(us % 1e3) === 500 && Math.abs(ms) % 2 === 1) {
55707
- ms -= 1;
55704
+ let ms2 = Math.round(us / 1e3);
55705
+ if (Math.abs(us % 1e3) === 500 && Math.abs(ms2) % 2 === 1) {
55706
+ ms2 -= 1;
55708
55707
  }
55709
- ms += TIMESHIFT;
55710
- return new Date(ms);
55708
+ ms2 += TIMESHIFT;
55709
+ return new Date(ms2);
55711
55710
  }
55712
55711
  };
55713
55712
  exports2.DateTimeCodec = DateTimeCodec;
@@ -55728,8 +55727,8 @@ var require_datetime2 = __commonJS({
55728
55727
  if (!(object instanceof datetime_1.LocalDateTime)) {
55729
55728
  throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
55730
55729
  }
55731
- const ms = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
55732
- let us = ms * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
55730
+ const ms2 = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
55731
+ let us = ms2 * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
55733
55732
  if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
55734
55733
  us += 1n;
55735
55734
  }
@@ -55743,13 +55742,13 @@ var require_datetime2 = __commonJS({
55743
55742
  }
55744
55743
  const bi_ms = bi_us / 1000n;
55745
55744
  let us = Number(bi_us - bi_ms * 1000n);
55746
- let ms = Number(bi_ms);
55745
+ let ms2 = Number(bi_ms);
55747
55746
  if (us < 0) {
55748
55747
  us += 1e3;
55749
- ms -= 1;
55748
+ ms2 -= 1;
55750
55749
  }
55751
- ms += TIMESHIFT;
55752
- const date2 = new Date(ms);
55750
+ ms2 += TIMESHIFT;
55751
+ const date2 = new Date(ms2);
55753
55752
  return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
55754
55753
  }
55755
55754
  };
@@ -55811,13 +55810,13 @@ var require_datetime2 = __commonJS({
55811
55810
  }
55812
55811
  let us = Number(bius);
55813
55812
  let seconds = Math.floor(us / 1e6);
55814
- const ms = Math.floor(us % 1e6 / 1e3);
55815
- us = us % 1e6 - ms * 1e3;
55813
+ const ms2 = Math.floor(us % 1e6 / 1e3);
55814
+ us = us % 1e6 - ms2 * 1e3;
55816
55815
  let minutes = Math.floor(seconds / 60);
55817
55816
  seconds = Math.floor(seconds % 60);
55818
55817
  const hours = Math.floor(minutes / 60);
55819
55818
  minutes = Math.floor(minutes % 60);
55820
- return new datetime_1.LocalTime(hours, minutes, seconds, ms, us);
55819
+ return new datetime_1.LocalTime(hours, minutes, seconds, ms2, us);
55821
55820
  }
55822
55821
  };
55823
55822
  exports2.LocalTimeCodec = LocalTimeCodec;
@@ -55894,14 +55893,14 @@ var require_datetime2 = __commonJS({
55894
55893
  const biMillion = 1000000n;
55895
55894
  const biSeconds = bius / biMillion;
55896
55895
  let us = Number(bius - biSeconds * biMillion);
55897
- const ms = Math.floor(us / 1e3);
55896
+ const ms2 = Math.floor(us / 1e3);
55898
55897
  us = us % 1e3;
55899
55898
  let seconds = Number(biSeconds);
55900
55899
  let minutes = Math.floor(seconds / 60);
55901
55900
  seconds = Math.floor(seconds % 60);
55902
55901
  const hours = Math.floor(minutes / 60);
55903
55902
  minutes = Math.floor(minutes % 60);
55904
- return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
55903
+ return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
55905
55904
  }
55906
55905
  };
55907
55906
  exports2.DurationCodec = DurationCodec;
@@ -55947,7 +55946,7 @@ var require_datetime2 = __commonJS({
55947
55946
  const million = BigInt(1e6);
55948
55947
  const biSeconds = bius / million;
55949
55948
  let us = Number(bius - biSeconds * million);
55950
- const ms = Math.trunc(us / 1e3);
55949
+ const ms2 = Math.trunc(us / 1e3);
55951
55950
  us = us % 1e3;
55952
55951
  let seconds = Number(biSeconds);
55953
55952
  let minutes = Math.trunc(seconds / 60);
@@ -55958,7 +55957,7 @@ var require_datetime2 = __commonJS({
55958
55957
  days = Math.trunc(days % 7);
55959
55958
  const years = Math.trunc(months2 / 12);
55960
55959
  months2 = Math.trunc(months2 % 12);
55961
- return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
55960
+ return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
55962
55961
  }
55963
55962
  };
55964
55963
  exports2.RelativeDurationCodec = RelativeDurationCodec;
@@ -66122,41 +66121,41 @@ var require_ms = __commonJS({
66122
66121
  return void 0;
66123
66122
  }
66124
66123
  }
66125
- function fmtShort(ms) {
66126
- var msAbs = Math.abs(ms);
66124
+ function fmtShort(ms2) {
66125
+ var msAbs = Math.abs(ms2);
66127
66126
  if (msAbs >= d6) {
66128
- return Math.round(ms / d6) + "d";
66127
+ return Math.round(ms2 / d6) + "d";
66129
66128
  }
66130
66129
  if (msAbs >= h7) {
66131
- return Math.round(ms / h7) + "h";
66130
+ return Math.round(ms2 / h7) + "h";
66132
66131
  }
66133
66132
  if (msAbs >= m7) {
66134
- return Math.round(ms / m7) + "m";
66133
+ return Math.round(ms2 / m7) + "m";
66135
66134
  }
66136
66135
  if (msAbs >= s7) {
66137
- return Math.round(ms / s7) + "s";
66136
+ return Math.round(ms2 / s7) + "s";
66138
66137
  }
66139
- return ms + "ms";
66138
+ return ms2 + "ms";
66140
66139
  }
66141
- function fmtLong(ms) {
66142
- var msAbs = Math.abs(ms);
66140
+ function fmtLong(ms2) {
66141
+ var msAbs = Math.abs(ms2);
66143
66142
  if (msAbs >= d6) {
66144
- return plural(ms, msAbs, d6, "day");
66143
+ return plural(ms2, msAbs, d6, "day");
66145
66144
  }
66146
66145
  if (msAbs >= h7) {
66147
- return plural(ms, msAbs, h7, "hour");
66146
+ return plural(ms2, msAbs, h7, "hour");
66148
66147
  }
66149
66148
  if (msAbs >= m7) {
66150
- return plural(ms, msAbs, m7, "minute");
66149
+ return plural(ms2, msAbs, m7, "minute");
66151
66150
  }
66152
66151
  if (msAbs >= s7) {
66153
- return plural(ms, msAbs, s7, "second");
66152
+ return plural(ms2, msAbs, s7, "second");
66154
66153
  }
66155
- return ms + " ms";
66154
+ return ms2 + " ms";
66156
66155
  }
66157
- function plural(ms, msAbs, n6, name) {
66156
+ function plural(ms2, msAbs, n6, name) {
66158
66157
  var isPlural = msAbs >= n6 * 1.5;
66159
- return Math.round(ms / n6) + " " + name + (isPlural ? "s" : "");
66158
+ return Math.round(ms2 / n6) + " " + name + (isPlural ? "s" : "");
66160
66159
  }
66161
66160
  }
66162
66161
  });
@@ -66200,8 +66199,8 @@ var require_common2 = __commonJS({
66200
66199
  }
66201
66200
  const self2 = debug;
66202
66201
  const curr = Number(/* @__PURE__ */ new Date());
66203
- const ms = curr - (prevTime || curr);
66204
- self2.diff = ms;
66202
+ const ms2 = curr - (prevTime || curr);
66203
+ self2.diff = ms2;
66205
66204
  self2.prev = prevTime;
66206
66205
  self2.curr = curr;
66207
66206
  prevTime = curr;
@@ -81704,11 +81703,11 @@ var require_TokenExpiredError = __commonJS({
81704
81703
  var require_timespan = __commonJS({
81705
81704
  "../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module) {
81706
81705
  "use strict";
81707
- var ms = require_ms();
81706
+ var ms2 = require_ms();
81708
81707
  module.exports = function(time2, iat) {
81709
81708
  var timestamp = iat || Math.floor(Date.now() / 1e3);
81710
81709
  if (typeof time2 === "string") {
81711
- var milliseconds = ms(time2);
81710
+ var milliseconds = ms2(time2);
81712
81711
  if (typeof milliseconds === "undefined") {
81713
81712
  return;
81714
81713
  }
@@ -96246,7 +96245,7 @@ var require_dist = __commonJS({
96246
96245
  };
96247
96246
  Object.defineProperty(exports2, "__esModule", { value: true });
96248
96247
  exports2.Agent = void 0;
96249
- var net = __importStar2(__require("net"));
96248
+ var net2 = __importStar2(__require("net"));
96250
96249
  var http3 = __importStar2(__require("http"));
96251
96250
  var https_1 = __require("https");
96252
96251
  __exportStar2(require_helpers2(), exports2);
@@ -96286,7 +96285,7 @@ var require_dist = __commonJS({
96286
96285
  if (!this.sockets[name]) {
96287
96286
  this.sockets[name] = [];
96288
96287
  }
96289
- const fakeSocket = new net.Socket({ writable: false });
96288
+ const fakeSocket = new net2.Socket({ writable: false });
96290
96289
  this.sockets[name].push(fakeSocket);
96291
96290
  this.totalSocketCount++;
96292
96291
  return fakeSocket;
@@ -96498,7 +96497,7 @@ var require_dist2 = __commonJS({
96498
96497
  };
96499
96498
  Object.defineProperty(exports2, "__esModule", { value: true });
96500
96499
  exports2.HttpsProxyAgent = void 0;
96501
- var net = __importStar2(__require("net"));
96500
+ var net2 = __importStar2(__require("net"));
96502
96501
  var tls = __importStar2(__require("tls"));
96503
96502
  var assert_1 = __importDefault2(__require("assert"));
96504
96503
  var debug_1 = __importDefault2(require_src2());
@@ -96507,7 +96506,7 @@ var require_dist2 = __commonJS({
96507
96506
  var parse_proxy_response_1 = require_parse_proxy_response();
96508
96507
  var debug = (0, debug_1.default)("https-proxy-agent");
96509
96508
  var setServernameFromNonIpHost = (options) => {
96510
- if (options.servername === void 0 && options.host && !net.isIP(options.host)) {
96509
+ if (options.servername === void 0 && options.host && !net2.isIP(options.host)) {
96511
96510
  return {
96512
96511
  ...options,
96513
96512
  servername: options.host
@@ -96547,10 +96546,10 @@ var require_dist2 = __commonJS({
96547
96546
  socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
96548
96547
  } else {
96549
96548
  debug("Creating `net.Socket`: %o", this.connectOpts);
96550
- socket = net.connect(this.connectOpts);
96549
+ socket = net2.connect(this.connectOpts);
96551
96550
  }
96552
96551
  const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
96553
- const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
96552
+ const host = net2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
96554
96553
  let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
96555
96554
  `;
96556
96555
  if (proxy.username || proxy.password) {
@@ -96583,7 +96582,7 @@ var require_dist2 = __commonJS({
96583
96582
  return socket;
96584
96583
  }
96585
96584
  socket.destroy();
96586
- const fakeSocket = new net.Socket({ writable: false });
96585
+ const fakeSocket = new net2.Socket({ writable: false });
96587
96586
  fakeSocket.readable = true;
96588
96587
  req.once("socket", (s7) => {
96589
96588
  debug("Replaying proxy buffer for failed request");
@@ -96648,7 +96647,7 @@ var require_dist3 = __commonJS({
96648
96647
  };
96649
96648
  Object.defineProperty(exports2, "__esModule", { value: true });
96650
96649
  exports2.HttpProxyAgent = void 0;
96651
- var net = __importStar2(__require("net"));
96650
+ var net2 = __importStar2(__require("net"));
96652
96651
  var tls = __importStar2(__require("tls"));
96653
96652
  var debug_1 = __importDefault2(require_src2());
96654
96653
  var events_1 = __require("events");
@@ -96721,7 +96720,7 @@ var require_dist3 = __commonJS({
96721
96720
  socket = tls.connect(this.connectOpts);
96722
96721
  } else {
96723
96722
  debug("Creating `net.Socket`: %o", this.connectOpts);
96724
- socket = net.connect(this.connectOpts);
96723
+ socket = net2.connect(this.connectOpts);
96725
96724
  }
96726
96725
  await (0, events_1.once)(socket, "connect");
96727
96726
  return socket;
@@ -135600,7 +135599,7 @@ var require_connection = __commonJS({
135600
135599
  var _crypto = _interopRequireDefault(__require("crypto"));
135601
135600
  var _os = _interopRequireDefault(__require("os"));
135602
135601
  var tls = _interopRequireWildcard(__require("tls"));
135603
- var net = _interopRequireWildcard(__require("net"));
135602
+ var net2 = _interopRequireWildcard(__require("net"));
135604
135603
  var _dns = _interopRequireDefault(__require("dns"));
135605
135604
  var _constants = _interopRequireDefault(__require("constants"));
135606
135605
  var _stream = __require("stream");
@@ -136649,7 +136648,7 @@ var require_connection = __commonJS({
136649
136648
  async wrapWithTls(socket, signal) {
136650
136649
  signal.throwIfAborted();
136651
136650
  const secureContext = tls.createSecureContext(this.secureContextOptions);
136652
- const serverName = !net.isIP(this.config.server) ? this.config.server : "";
136651
+ const serverName = !net2.isIP(this.config.server) ? this.config.server : "";
136653
136652
  const encryptOptions = {
136654
136653
  host: this.config.server,
136655
136654
  socket,
@@ -139555,10 +139554,10 @@ __export(connections_exports, {
139555
139554
  connectToSQLite: () => connectToSQLite,
139556
139555
  connectToSingleStore: () => connectToSingleStore,
139557
139556
  prepareCockroach: () => prepareCockroach,
139558
- prepareDuckDb: () => prepareDuckDb,
139559
139557
  prepareGelDB: () => prepareGelDB,
139560
139558
  preparePostgresDB: () => preparePostgresDB
139561
139559
  });
139560
+ import net from "net";
139562
139561
  function parseMssqlUrl(url) {
139563
139562
  return {
139564
139563
  user: url.username,
@@ -139572,7 +139571,7 @@ function parseMssqlUrl(url) {
139572
139571
  }
139573
139572
  };
139574
139573
  }
139575
- var normalisePGliteUrl, preparePostgresDB, prepareDuckDb, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
139574
+ var ms, normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
139576
139575
  var init_connections = __esm({
139577
139576
  "src/cli/connections.ts"() {
139578
139577
  "use strict";
@@ -139583,6 +139582,7 @@ var init_connections = __esm({
139583
139582
  init_when_json_met_bigint();
139584
139583
  init_utils3();
139585
139584
  init_outputs();
139585
+ ms = (a6, b6) => Number(b6 - a6) / 1e6;
139586
139586
  normalisePGliteUrl = (it) => {
139587
139587
  if (it.startsWith("file:")) {
139588
139588
  return it.substring(5);
@@ -139706,13 +139706,7 @@ var init_connections = __esm({
139706
139706
  }
139707
139707
  return results;
139708
139708
  };
139709
- return {
139710
- packageName: "pglite",
139711
- query,
139712
- proxy,
139713
- transactionProxy,
139714
- migrate: migrateFn
139715
- };
139709
+ return { packageName: "pglite", query, proxy, transactionProxy, migrate: migrateFn };
139716
139710
  }
139717
139711
  assertUnreachable(driver2);
139718
139712
  }
@@ -139743,13 +139737,13 @@ var init_connections = __esm({
139743
139737
  return pg.types.getTypeParser(typeId, format2);
139744
139738
  }
139745
139739
  };
139746
- const client = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
139747
- const db = drizzle({ client });
139740
+ const pool = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
139741
+ const db = drizzle({ client: pool });
139748
139742
  const migrateFn = async (config) => {
139749
139743
  return migrate(db, config);
139750
139744
  };
139751
139745
  const query = async (sql, params) => {
139752
- const result2 = await client.query({
139746
+ const result2 = await pool.query({
139753
139747
  text: sql,
139754
139748
  values: params ?? [],
139755
139749
  types: types3
@@ -139759,7 +139753,7 @@ var init_connections = __esm({
139759
139753
  return result2.rows;
139760
139754
  };
139761
139755
  const proxy = async (params) => {
139762
- const result2 = await client.query({
139756
+ const result2 = await pool.query({
139763
139757
  text: params.sql,
139764
139758
  values: params.params,
139765
139759
  ...params.mode === "array" && { rowMode: "array" },
@@ -139771,7 +139765,7 @@ var init_connections = __esm({
139771
139765
  };
139772
139766
  const transactionProxy = async (queries) => {
139773
139767
  const results = [];
139774
- const tx = await client.connect();
139768
+ const tx = await pool.connect();
139775
139769
  try {
139776
139770
  await tx.query("BEGIN");
139777
139771
  for (const query2 of queries) {
@@ -139790,13 +139784,119 @@ var init_connections = __esm({
139790
139784
  }
139791
139785
  return results;
139792
139786
  };
139793
- return {
139794
- packageName: "pg",
139795
- query,
139796
- proxy,
139797
- transactionProxy,
139798
- migrate: migrateFn
139787
+ const benchmarkQuery = async (client, sql, params) => {
139788
+ const explainResult = await pool.query({
139789
+ text: `EXPLAIN ANALYZE ${sql}`,
139790
+ values: params ?? [],
139791
+ types: types3
139792
+ });
139793
+ const stringifiedResult = JSON.stringify(explainResult.rows);
139794
+ const planningMatch = stringifiedResult.match(/Planning Time:\s*([\d.]+)\s*ms/i);
139795
+ const executionMatch = stringifiedResult.match(/Execution Time:\s*([\d.]+)\s*ms/i);
139796
+ let planningTime = Number(planningMatch[1]);
139797
+ let executionTime = Number(executionMatch[1]);
139798
+ let querySentAt = 0n;
139799
+ let firstDataAt = 0n;
139800
+ let lastDataAt = 0n;
139801
+ let lastRowParsedAt = 0n;
139802
+ let queryCompletedAt = 0n;
139803
+ let bytesReceived = 0;
139804
+ let rowCount = 0;
139805
+ let parseTime = 0;
139806
+ let lastParseTime = 0;
139807
+ const rowDescriptionListener = (data) => {
139808
+ if (firstDataAt === 0n) {
139809
+ firstDataAt = process.hrtime.bigint();
139810
+ }
139811
+ bytesReceived += data.length;
139812
+ };
139813
+ const originalRowListener = client.connection.listeners("dataRow")[0];
139814
+ const wrappedRowListener = (data) => {
139815
+ rowCount += 1;
139816
+ const start = process.hrtime.bigint();
139817
+ lastDataAt = start;
139818
+ originalRowListener.apply(client.connection, [data]);
139819
+ const end2 = process.hrtime.bigint();
139820
+ lastRowParsedAt = end2;
139821
+ lastParseTime = ms(start, end2);
139822
+ parseTime += lastParseTime;
139823
+ bytesReceived += data.length;
139824
+ };
139825
+ client.connection.removeAllListeners("dataRow");
139826
+ client.connection.addListener("dataRow", wrappedRowListener);
139827
+ client.connection.prependListener("rowDescription", rowDescriptionListener);
139828
+ querySentAt = process.hrtime.bigint();
139829
+ await client.query({
139830
+ text: sql,
139831
+ values: params,
139832
+ types: types3
139833
+ });
139834
+ queryCompletedAt = process.hrtime.bigint();
139835
+ client.connection.removeListener("rowDescription", rowDescriptionListener);
139836
+ client.connection.removeAllListeners("dataRow");
139837
+ client.connection.addListener("dataRow", originalRowListener);
139838
+ let querySentTime = ms(querySentAt, firstDataAt) - executionTime - planningTime;
139839
+ if (querySentTime < 0) {
139840
+ const percent = 0.1;
139841
+ const overflow = -querySentTime;
139842
+ const keepForSent = overflow * percent;
139843
+ const adjustedOverflow = overflow * (1 + percent);
139844
+ const total2 = planningTime + executionTime;
139845
+ const ratioPlanning = planningTime / total2;
139846
+ const ratioExecution = executionTime / total2;
139847
+ planningTime -= adjustedOverflow * ratioPlanning;
139848
+ executionTime -= adjustedOverflow * ratioExecution;
139849
+ querySentTime = keepForSent;
139850
+ }
139851
+ const networkLatencyBefore = querySentTime / 2;
139852
+ const networkLatencyAfter = querySentTime / 2;
139853
+ const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
139854
+ const total = ms(querySentAt, queryCompletedAt);
139855
+ const calculatedTotal = networkLatencyBefore + planningTime + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
139856
+ const errorMargin = Math.abs(total - calculatedTotal);
139857
+ return {
139858
+ networkLatencyBefore,
139859
+ planning: planningTime,
139860
+ execution: executionTime,
139861
+ networkLatencyAfter,
139862
+ dataDownload: downloadTime,
139863
+ dataParse: parseTime,
139864
+ total,
139865
+ errorMargin,
139866
+ dataSize: bytesReceived
139867
+ };
139868
+ };
139869
+ const benchmarkProxy = async ({ sql, params }, repeats) => {
139870
+ let startAt = 0n;
139871
+ let tcpConnectedAt = 0n;
139872
+ let tlsConnectedAt = null;
139873
+ let dbReadyAt = 0n;
139874
+ const client = "url" in credentials ? new pg.Client({ connectionString: credentials.url }) : new pg.Client({ ...credentials, ssl });
139875
+ client.connection.once("connect", () => {
139876
+ tcpConnectedAt = process.hrtime.bigint();
139877
+ });
139878
+ client.connection.prependOnceListener("sslconnect", () => {
139879
+ tlsConnectedAt = process.hrtime.bigint();
139880
+ });
139881
+ client.connection.prependOnceListener("readyForQuery", () => {
139882
+ dbReadyAt = process.hrtime.bigint();
139883
+ });
139884
+ startAt = process.hrtime.bigint();
139885
+ await client.connect();
139886
+ const results = [];
139887
+ for (let i7 = 0; i7 < repeats; i7++) {
139888
+ const r7 = await benchmarkQuery(client, sql, params);
139889
+ results.push(r7);
139890
+ }
139891
+ await client.end();
139892
+ return {
139893
+ tcpHandshake: ms(startAt, tcpConnectedAt),
139894
+ tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
139895
+ dbHandshake: ms(tlsConnectedAt ?? tcpConnectedAt, dbReadyAt),
139896
+ queries: results
139897
+ };
139799
139898
  };
139899
+ return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
139800
139900
  }
139801
139901
  if (await checkPackage("postgres")) {
139802
139902
  console.log(
@@ -139847,13 +139947,7 @@ var init_connections = __esm({
139847
139947
  }
139848
139948
  return results;
139849
139949
  };
139850
- return {
139851
- packageName: "postgres",
139852
- query,
139853
- proxy,
139854
- transactionProxy,
139855
- migrate: migrateFn
139856
- };
139950
+ return { packageName: "postgres", query, proxy, transactionProxy, migrate: migrateFn };
139857
139951
  }
139858
139952
  if (await checkPackage("@vercel/postgres")) {
139859
139953
  console.log(
@@ -139934,13 +140028,7 @@ var init_connections = __esm({
139934
140028
  }
139935
140029
  return results;
139936
140030
  };
139937
- return {
139938
- packageName: "@vercel/postgres",
139939
- query,
139940
- proxy,
139941
- transactionProxy,
139942
- migrate: migrateFn
139943
- };
140031
+ return { packageName: "@vercel/postgres", query, proxy, transactionProxy, migrate: migrateFn };
139944
140032
  }
139945
140033
  if (await checkPackage("@neondatabase/serverless")) {
139946
140034
  console.log(
@@ -139953,11 +140041,7 @@ var init_connections = __esm({
139953
140041
  "'@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
139954
140042
  )
139955
140043
  );
139956
- const {
139957
- Pool,
139958
- neonConfig,
139959
- types: pgTypes
139960
- } = await import("@neondatabase/serverless");
140044
+ const { Pool, neonConfig, types: pgTypes } = await import("@neondatabase/serverless");
139961
140045
  const { drizzle } = await import("drizzle-orm/neon-serverless");
139962
140046
  const { migrate } = await import("drizzle-orm/neon-serverless/migrator");
139963
140047
  const ssl = "ssl" in credentials ? credentials.ssl === "prefer" || credentials.ssl === "require" || credentials.ssl === "allow" ? { rejectUnauthorized: false } : credentials.ssl === "verify-full" ? {} : credentials.ssl : {};
@@ -140027,13 +140111,7 @@ var init_connections = __esm({
140027
140111
  }
140028
140112
  return results;
140029
140113
  };
140030
- return {
140031
- packageName: "@neondatabase/serverless",
140032
- query,
140033
- proxy,
140034
- transactionProxy,
140035
- migrate: migrateFn
140036
- };
140114
+ return { packageName: "@neondatabase/serverless", query, proxy, transactionProxy, migrate: migrateFn };
140037
140115
  }
140038
140116
  if (await checkPackage("bun")) {
140039
140117
  console.log(withStyle.info(`Using 'bun' driver for database querying`));
@@ -140084,54 +140162,6 @@ var init_connections = __esm({
140084
140162
  console.warn("For the 'bun' driver, run your script using: bun --bun");
140085
140163
  process.exit(1);
140086
140164
  };
140087
- prepareDuckDb = async (credentials) => {
140088
- if (await checkPackage("@duckdb/node-api")) {
140089
- console.log(
140090
- withStyle.info(`Using '@duckdb/node-api' driver for database querying`)
140091
- );
140092
- const { DuckDBInstance } = await import("@duckdb/node-api");
140093
- const instance = await DuckDBInstance.create(credentials.url);
140094
- const client = await instance.connect();
140095
- const query = async (sql, params = []) => {
140096
- const result2 = await client.run(sql, params);
140097
- const rows = await result2.getRowObjectsJson();
140098
- return rows;
140099
- };
140100
- const proxy = async (params) => {
140101
- const result2 = await client.run(params.sql, params.params);
140102
- return params.mode === "array" ? await result2.getRowsJson() : await result2.getRowObjectsJson();
140103
- };
140104
- const transactionProxy = async (queries) => {
140105
- const results = [];
140106
- try {
140107
- await client.run("BEGIN");
140108
- for (const query2 of queries) {
140109
- const result2 = await client.run(query2.sql);
140110
- results.push(await result2.getRowObjectsJson());
140111
- }
140112
- await client.run("COMMIT");
140113
- } catch (error3) {
140114
- await client.run("ROLLBACK");
140115
- results.push(error3);
140116
- }
140117
- return results;
140118
- };
140119
- return {
140120
- packageName: "@duckdb/node-api",
140121
- query,
140122
- proxy,
140123
- transactionProxy,
140124
- migrate: () => {
140125
- throw new Error("DuckDB does not support migrations");
140126
- }
140127
- };
140128
- }
140129
- console.error(
140130
- // "To connect to DuckDb database - please install either of 'duckdb', '@duckdb/node-api' drivers",
140131
- "To connect to DuckDb database - please install '@duckdb/node-api' driver"
140132
- );
140133
- process.exit(1);
140134
- };
140135
140165
  prepareCockroach = async (credentials) => {
140136
140166
  if (await checkPackage("pg")) {
140137
140167
  const { default: pg } = await import("pg");
@@ -140184,7 +140214,9 @@ var init_connections = __esm({
140184
140214
  };
140185
140215
  return { query, proxy, migrate: migrateFn };
140186
140216
  }
140187
- console.error("To connect to Cockroach - please install 'pg' package");
140217
+ console.error(
140218
+ "To connect to Cockroach - please install 'pg' package"
140219
+ );
140188
140220
  process.exit(1);
140189
140221
  };
140190
140222
  prepareGelDB = async (credentials) => {
@@ -140243,7 +140275,9 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140243
140275
  };
140244
140276
  return { packageName: "gel", query, proxy, transactionProxy };
140245
140277
  }
140246
- console.error("To connect to gel database - please install 'edgedb' driver");
140278
+ console.error(
140279
+ "To connect to gel database - please install 'edgedb' driver"
140280
+ );
140247
140281
  process.exit(1);
140248
140282
  };
140249
140283
  parseSingleStoreCredentials = (credentials) => {
@@ -140357,7 +140391,6 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140357
140391
  }
140358
140392
  return next();
140359
140393
  };
140360
- await connection.connect();
140361
140394
  const query = async (sql, params) => {
140362
140395
  const res = await connection.execute({
140363
140396
  sql,
@@ -140397,11 +140430,156 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140397
140430
  }
140398
140431
  return results;
140399
140432
  };
140433
+ const benchmarkQuery = async (newConnection, sql, params) => {
140434
+ const explainResult = await connection.query({
140435
+ sql: `EXPLAIN ANALYZE ${sql}`,
140436
+ values: params ?? [],
140437
+ typeCast
140438
+ });
140439
+ const stringifiedResult = JSON.stringify(explainResult[0]);
140440
+ const timeMatch = stringifiedResult.match(
140441
+ /actual time=([0-9.eE+-]+)\.\.([0-9.eE+-]+)/
140442
+ );
140443
+ const lastRowTime = Number(timeMatch[2]);
140444
+ let executionTime = lastRowTime;
140445
+ let querySentAt = 0n;
140446
+ let firstDataAt = 0n;
140447
+ let lastDataAt = 0n;
140448
+ let lastRowParsedAt = 0n;
140449
+ let queryCompletedAt = 0n;
140450
+ let bytesReceived = 0;
140451
+ let rowCount = 0;
140452
+ let parseTime = 0;
140453
+ let lastParseTime = 0;
140454
+ querySentAt = process.hrtime.bigint();
140455
+ await new Promise((resolve2, reject) => {
140456
+ const query2 = newConnection.query({
140457
+ sql,
140458
+ values: params ?? [],
140459
+ typeCast
140460
+ });
140461
+ const originalRowHandler = query2.row;
140462
+ let packets = 0;
140463
+ const wrappedRowListener = (packet, connection2) => {
140464
+ packets += 1;
140465
+ if (firstDataAt === 0n) {
140466
+ firstDataAt = process.hrtime.bigint();
140467
+ bytesReceived += packet.start;
140468
+ }
140469
+ const start = process.hrtime.bigint();
140470
+ lastDataAt = start;
140471
+ const res = originalRowHandler.apply(query2, [packet, connection2]);
140472
+ const end2 = process.hrtime.bigint();
140473
+ lastRowParsedAt = end2;
140474
+ lastParseTime = ms(start, end2);
140475
+ parseTime += lastParseTime;
140476
+ bytesReceived += packet.length();
140477
+ if (!res || packet.isEOF()) {
140478
+ return res;
140479
+ }
140480
+ return wrappedRowListener;
140481
+ };
140482
+ query2.row = wrappedRowListener;
140483
+ query2.on("result", () => {
140484
+ rowCount += 1;
140485
+ });
140486
+ query2.on("error", (err2) => {
140487
+ reject(err2);
140488
+ });
140489
+ query2.on("end", () => {
140490
+ resolve2();
140491
+ });
140492
+ });
140493
+ queryCompletedAt = process.hrtime.bigint();
140494
+ let querySentTime = ms(querySentAt, firstDataAt) - executionTime;
140495
+ if (querySentTime < 0) {
140496
+ const percent = 0.1;
140497
+ const overflow = -querySentTime;
140498
+ const keepForSent = overflow * percent;
140499
+ const adjustedOverflow = overflow * (1 + percent);
140500
+ const total2 = executionTime;
140501
+ const ratioExecution = executionTime / total2;
140502
+ executionTime -= adjustedOverflow * ratioExecution;
140503
+ querySentTime = keepForSent;
140504
+ }
140505
+ const networkLatencyBefore = querySentTime / 2;
140506
+ const networkLatencyAfter = querySentTime / 2;
140507
+ const downloadTime = ms(firstDataAt, lastDataAt) - (rowCount > 1 ? parseTime - lastParseTime : 0);
140508
+ const total = ms(querySentAt, queryCompletedAt);
140509
+ const calculatedTotal = networkLatencyBefore + executionTime + networkLatencyAfter + downloadTime + parseTime + ms(lastRowParsedAt, queryCompletedAt);
140510
+ const errorMargin = Math.abs(total - calculatedTotal);
140511
+ return {
140512
+ networkLatencyBefore,
140513
+ planning: null,
140514
+ execution: executionTime,
140515
+ networkLatencyAfter,
140516
+ dataDownload: downloadTime,
140517
+ dataParse: parseTime,
140518
+ total,
140519
+ errorMargin,
140520
+ dataSize: bytesReceived
140521
+ };
140522
+ };
140523
+ const benchmarkProxy = async ({ sql, params }, repeats) => {
140524
+ const { createConnection: createConnection2 } = await import("mysql2");
140525
+ let startAt = 0n;
140526
+ let tcpConnectedAt = 0n;
140527
+ let tlsConnectedAt = null;
140528
+ const createStream = ({ config }) => {
140529
+ let stream;
140530
+ if (config.socketPath) {
140531
+ stream = net.connect(config.socketPath);
140532
+ } else {
140533
+ stream = net.connect(config.port, config.host);
140534
+ }
140535
+ if (config.enableKeepAlive) {
140536
+ stream.on("connect", () => {
140537
+ stream.setKeepAlive(true, config.keepAliveInitialDelay);
140538
+ });
140539
+ }
140540
+ stream.setNoDelay(true);
140541
+ stream.once("connect", () => {
140542
+ tcpConnectedAt = process.hrtime.bigint();
140543
+ });
140544
+ return stream;
140545
+ };
140546
+ startAt = process.hrtime.bigint();
140547
+ const connection2 = result2.url ? createConnection2({
140548
+ uri: result2.url,
140549
+ stream: createStream
140550
+ }) : createConnection2({
140551
+ ...result2.credentials,
140552
+ stream: createStream
140553
+ });
140554
+ await new Promise((resolve2, reject) => {
140555
+ connection2.connect((err2) => {
140556
+ tlsConnectedAt = process.hrtime.bigint();
140557
+ if (err2) {
140558
+ reject(err2);
140559
+ } else {
140560
+ resolve2();
140561
+ }
140562
+ });
140563
+ });
140564
+ const results = [];
140565
+ for (let i7 = 0; i7 < repeats; i7++) {
140566
+ const r7 = await benchmarkQuery(connection2, sql, params);
140567
+ results.push(r7);
140568
+ }
140569
+ connection2.end();
140570
+ return {
140571
+ tcpHandshake: ms(startAt, tcpConnectedAt),
140572
+ tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
140573
+ dbHandshake: null,
140574
+ queries: results
140575
+ };
140576
+ };
140400
140577
  return {
140401
140578
  db: { query },
140402
140579
  packageName: "mysql2",
140403
140580
  proxy,
140404
140581
  transactionProxy,
140582
+ benchmarkProxy,
140405
140583
  database: result2.database,
140406
140584
  migrate: migrateFn
140407
140585
  };
@@ -140551,7 +140729,9 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140551
140729
  migrate: migrateFn
140552
140730
  };
140553
140731
  }
140554
- console.error("To connect to MsSQL database - please install 'mssql' driver");
140732
+ console.error(
140733
+ "To connect to MsSQL database - please install 'mssql' driver"
140734
+ );
140555
140735
  process.exit(1);
140556
140736
  };
140557
140737
  prepareSqliteParams = (params, driver2) => {
@@ -140656,10 +140836,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140656
140836
  await remoteCallback(query2, [], "run");
140657
140837
  };
140658
140838
  const proxy = async (params) => {
140659
- const preparedParams = prepareSqliteParams(
140660
- params.params || [],
140661
- "d1-http"
140662
- );
140839
+ const preparedParams = prepareSqliteParams(params.params || [], "d1-http");
140663
140840
  const result2 = await remoteCallback(
140664
140841
  params.sql,
140665
140842
  preparedParams,
@@ -140884,19 +141061,17 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140884
141061
  };
140885
141062
  const transactionProxy = async (queries) => {
140886
141063
  const results = [];
140887
- const tx = sqlite.transaction(
140888
- (queries2) => {
140889
- for (const query of queries2) {
140890
- let result2 = [];
140891
- if (query.method === "values" || query.method === "get" || query.method === "all") {
140892
- result2 = sqlite.prepare(query.sql).all();
140893
- } else {
140894
- sqlite.prepare(query.sql).run();
140895
- }
140896
- results.push(result2);
141064
+ const tx = sqlite.transaction((queries2) => {
141065
+ for (const query of queries2) {
141066
+ let result2 = [];
141067
+ if (query.method === "values" || query.method === "get" || query.method === "all") {
141068
+ result2 = sqlite.prepare(query.sql).all();
141069
+ } else {
141070
+ sqlite.prepare(query.sql).run();
140897
141071
  }
141072
+ results.push(result2);
140898
141073
  }
140899
- );
141074
+ });
140900
141075
  try {
140901
141076
  tx(queries);
140902
141077
  } catch (error3) {
@@ -140904,13 +141079,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
140904
141079
  }
140905
141080
  return results;
140906
141081
  };
140907
- return {
140908
- ...db,
140909
- packageName: "better-sqlite3",
140910
- proxy,
140911
- transactionProxy,
140912
- migrate: migrateFn
140913
- };
141082
+ return { ...db, packageName: "better-sqlite3", proxy, transactionProxy, migrate: migrateFn };
140914
141083
  }
140915
141084
  if (await checkPackage("bun")) {
140916
141085
  console.log(withStyle.info(`Using 'bun' driver for database querying`));
@@ -141040,7 +141209,6 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
141040
141209
  // src/cli/commands/studio.ts
141041
141210
  var studio_exports = {};
141042
141211
  __export(studio_exports, {
141043
- drizzleForDuckDb: () => drizzleForDuckDb,
141044
141212
  drizzleForLibSQL: () => drizzleForLibSQL,
141045
141213
  drizzleForMySQL: () => drizzleForMySQL,
141046
141214
  drizzleForPostgres: () => drizzleForPostgres,
@@ -141071,7 +141239,7 @@ import { getTableConfig as singlestoreTableConfig, SingleStoreTable } from "driz
141071
141239
  import { getTableConfig as sqliteTableConfig, SQLiteTable } from "drizzle-orm/sqlite-core";
141072
141240
  import fs9 from "fs";
141073
141241
  import { createServer } from "https";
141074
- var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForDuckDb, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
141242
+ var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, benchmarkProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
141075
141243
  var init_studio = __esm({
141076
141244
  "src/cli/commands/studio.ts"() {
141077
141245
  "use strict";
@@ -141285,6 +141453,7 @@ var init_studio = __esm({
141285
141453
  packageName: db.packageName,
141286
141454
  proxy: db.proxy,
141287
141455
  transactionProxy: db.transactionProxy,
141456
+ benchmarkProxy: db.benchmarkProxy,
141288
141457
  customDefaults,
141289
141458
  schema: pgSchema2,
141290
141459
  relations,
@@ -141292,26 +141461,9 @@ var init_studio = __esm({
141292
141461
  casing: casing2
141293
141462
  };
141294
141463
  };
141295
- drizzleForDuckDb = async (credentials) => {
141296
- const { prepareDuckDb: prepareDuckDb2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
141297
- const db = await prepareDuckDb2(credentials);
141298
- const dbUrl = `duckdb://${credentials.url}`;
141299
- const dbHash = createHash4("sha256").update(dbUrl).digest("hex");
141300
- return {
141301
- dbHash,
141302
- dialect: "duckdb",
141303
- driver: void 0,
141304
- packageName: db.packageName,
141305
- proxy: db.proxy,
141306
- transactionProxy: db.transactionProxy,
141307
- customDefaults: [],
141308
- schema: {},
141309
- relations: {}
141310
- };
141311
- };
141312
141464
  drizzleForMySQL = async (credentials, mysqlSchema, relations, schemaFiles, casing2) => {
141313
141465
  const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
141314
- const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials);
141466
+ const { proxy, transactionProxy, benchmarkProxy, database, packageName } = await connectToMySQL2(credentials);
141315
141467
  const customDefaults = getCustomDefaults(mysqlSchema, casing2);
141316
141468
  let dbUrl;
141317
141469
  if ("url" in credentials) {
@@ -141327,6 +141479,7 @@ var init_studio = __esm({
141327
141479
  databaseName: database,
141328
141480
  proxy,
141329
141481
  transactionProxy,
141482
+ benchmarkProxy,
141330
141483
  customDefaults,
141331
141484
  schema: mysqlSchema,
141332
141485
  relations,
@@ -141496,6 +141649,23 @@ var init_studio = __esm({
141496
141649
  ]).optional()
141497
141650
  }).array()
141498
141651
  });
141652
+ benchmarkProxySchema = external_exports.object({
141653
+ type: external_exports.literal("bproxy"),
141654
+ data: external_exports.object({
141655
+ query: external_exports.object({
141656
+ sql: external_exports.string(),
141657
+ params: external_exports.array(external_exports.any()).optional(),
141658
+ method: external_exports.union([
141659
+ external_exports.literal("values"),
141660
+ external_exports.literal("get"),
141661
+ external_exports.literal("all"),
141662
+ external_exports.literal("run"),
141663
+ external_exports.literal("execute")
141664
+ ]).optional()
141665
+ }),
141666
+ repeats: external_exports.number().min(1).optional()
141667
+ })
141668
+ });
141499
141669
  defaultsSchema = external_exports.object({
141500
141670
  type: external_exports.literal("defaults"),
141501
141671
  data: external_exports.array(
@@ -141510,6 +141680,7 @@ var init_studio = __esm({
141510
141680
  init2,
141511
141681
  proxySchema,
141512
141682
  transactionProxySchema,
141683
+ benchmarkProxySchema,
141513
141684
  defaultsSchema
141514
141685
  ]);
141515
141686
  jsonStringify = (data) => {
@@ -141532,6 +141703,7 @@ var init_studio = __esm({
141532
141703
  databaseName,
141533
141704
  proxy,
141534
141705
  transactionProxy,
141706
+ benchmarkProxy,
141535
141707
  customDefaults,
141536
141708
  schema: drizzleSchema,
141537
141709
  relations,
@@ -141595,7 +141767,7 @@ var init_studio = __esm({
141595
141767
  console.warn("Error message:", error3.message);
141596
141768
  }
141597
141769
  return c6.json({
141598
- version: "6.2",
141770
+ version: "6.3",
141599
141771
  dialect: dialect6,
141600
141772
  driver: driver2,
141601
141773
  packageName,
@@ -141633,6 +141805,21 @@ var init_studio = __esm({
141633
141805
  }
141634
141806
  );
141635
141807
  }
141808
+ if (type === "bproxy") {
141809
+ if (!benchmarkProxy) {
141810
+ throw new Error("Benchmark proxy is not configured for this database.");
141811
+ }
141812
+ const result2 = await benchmarkProxy(body.data.query, body.data.repeats || 1);
141813
+ const res = jsonStringify(result2);
141814
+ return c6.body(
141815
+ res,
141816
+ {
141817
+ headers: {
141818
+ "Content-Type": "application/json"
141819
+ }
141820
+ }
141821
+ );
141822
+ }
141636
141823
  if (type === "defaults") {
141637
141824
  const columns = body.data;
141638
141825
  const result2 = columns.map((column7) => {