drizzle-kit 0.31.0 → 0.31.1-08944da

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.
Files changed (6) hide show
  1. package/api.js +386 -349
  2. package/api.mjs +386 -349
  3. package/bin.cjs +17155 -18660
  4. package/package.json +10 -11
  5. package/utils.js +51 -181
  6. package/utils.mjs +51 -181
package/api.js CHANGED
@@ -35,7 +35,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
35
35
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
36
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
37
37
 
38
- // ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/ansi-styles/index.js
38
+ // ../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
39
39
  function assembleStyles() {
40
40
  const codes = /* @__PURE__ */ new Map();
41
41
  for (const [groupName, group] of Object.entries(styles)) {
@@ -152,7 +152,7 @@ function assembleStyles() {
152
152
  }
153
153
  var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
154
154
  var init_ansi_styles = __esm({
155
- "../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
155
+ "../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
156
156
  "use strict";
157
157
  ANSI_BACKGROUND_OFFSET = 10;
158
158
  wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
@@ -227,7 +227,7 @@ var init_ansi_styles = __esm({
227
227
  }
228
228
  });
229
229
 
230
- // ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/supports-color/index.js
230
+ // ../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js
231
231
  function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
232
232
  const prefix2 = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
233
233
  const position = argv.indexOf(prefix2 + flag);
@@ -291,10 +291,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
291
291
  return 1;
292
292
  }
293
293
  if ("CI" in env) {
294
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
294
+ if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
295
295
  return 3;
296
296
  }
297
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
297
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
298
298
  return 1;
299
299
  }
300
300
  return min2;
@@ -339,7 +339,7 @@ function createSupportsColor(stream, options = {}) {
339
339
  }
340
340
  var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
341
341
  var init_supports_color = __esm({
342
- "../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/vendor/supports-color/index.js"() {
342
+ "../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
343
343
  "use strict";
344
344
  import_node_process = __toESM(require("process"), 1);
345
345
  import_node_os = __toESM(require("os"), 1);
@@ -358,7 +358,7 @@ var init_supports_color = __esm({
358
358
  }
359
359
  });
360
360
 
361
- // ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/utilities.js
361
+ // ../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
362
362
  function stringReplaceAll(string, substring, replacer) {
363
363
  let index6 = string.indexOf(substring);
364
364
  if (index6 === -1) {
@@ -388,18 +388,18 @@ function stringEncaseCRLFWithFirstIndex(string, prefix2, postfix, index6) {
388
388
  return returnValue;
389
389
  }
390
390
  var init_utilities = __esm({
391
- "../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/utilities.js"() {
391
+ "../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js"() {
392
392
  "use strict";
393
393
  }
394
394
  });
395
395
 
396
- // ../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/index.js
396
+ // ../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js
397
397
  function createChalk(options) {
398
398
  return chalkFactory(options);
399
399
  }
400
400
  var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
401
401
  var init_source = __esm({
402
- "../node_modules/.pnpm/chalk@5.4.1/node_modules/chalk/source/index.js"() {
402
+ "../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js"() {
403
403
  "use strict";
404
404
  init_ansi_styles();
405
405
  init_supports_color();
@@ -3438,7 +3438,7 @@ var init_global = __esm({
3438
3438
  }
3439
3439
  });
3440
3440
 
3441
- // ../node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.mjs
3441
+ // ../node_modules/.pnpm/zod@3.23.7/node_modules/zod/lib/index.mjs
3442
3442
  function getErrorMap() {
3443
3443
  return overrideErrorMap;
3444
3444
  }
@@ -3450,11 +3450,8 @@ function addIssueToContext(ctx, issueData) {
3450
3450
  path: ctx.path,
3451
3451
  errorMaps: [
3452
3452
  ctx.common.contextualErrorMap,
3453
- // contextual error map is first priority
3454
3453
  ctx.schemaErrorMap,
3455
- // then schema-bound map if available
3456
3454
  overrideMap,
3457
- // then global override map
3458
3455
  overrideMap === errorMap ? void 0 : errorMap
3459
3456
  // then global default map
3460
3457
  ].filter((x) => !!x)
@@ -3526,33 +3523,6 @@ function isValidIP(ip, version2) {
3526
3523
  }
3527
3524
  return false;
3528
3525
  }
3529
- function isValidJWT(jwt, alg) {
3530
- if (!jwtRegex.test(jwt))
3531
- return false;
3532
- try {
3533
- const [header] = jwt.split(".");
3534
- const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
3535
- const decoded = JSON.parse(atob(base64));
3536
- if (typeof decoded !== "object" || decoded === null)
3537
- return false;
3538
- if (!decoded.typ || !decoded.alg)
3539
- return false;
3540
- if (alg && decoded.alg !== alg)
3541
- return false;
3542
- return true;
3543
- } catch (_a435) {
3544
- return false;
3545
- }
3546
- }
3547
- function isValidCidr(ip, version2) {
3548
- if ((version2 === "v4" || !version2) && ipv4CidrRegex.test(ip)) {
3549
- return true;
3550
- }
3551
- if ((version2 === "v6" || !version2) && ipv6CidrRegex.test(ip)) {
3552
- return true;
3553
- }
3554
- return false;
3555
- }
3556
3526
  function floatSafeRemainder(val, step) {
3557
3527
  const valDecCount = (val.toString().split(".")[1] || "").length;
3558
3528
  const stepDecCount = (step.toString().split(".")[1] || "").length;
@@ -3632,9 +3602,9 @@ function createZodEnum(values, params) {
3632
3602
  ...processCreateParams(params)
3633
3603
  });
3634
3604
  }
3635
- var util, objectUtil, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, _ZodEnum_cache, _ZodNativeEnum_cache, ParseInputLazyPath, handleResult, ZodType, cuidRegex, cuid2Regex, ulidRegex, uuidRegex, nanoidRegex, jwtRegex, durationRegex, emailRegex, _emojiRegex, emojiRegex, ipv4Regex, ipv4CidrRegex, ipv6Regex, ipv6CidrRegex, base64Regex, base64urlRegex, dateRegexSource, dateRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, ZodReadonly, late, ZodFirstPartyTypeKind, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType, coerce;
3605
+ var util, objectUtil, ZodParsedType, getParsedType, ZodIssueCode, ZodError, errorMap, overrideErrorMap, makeIssue, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync, errorUtil, _ZodEnum_cache, _ZodNativeEnum_cache, ParseInputLazyPath, handleResult, ZodType, cuidRegex, cuid2Regex, ulidRegex, uuidRegex, nanoidRegex, durationRegex, emailRegex, _emojiRegex, emojiRegex, ipv4Regex, ipv6Regex, base64Regex, dateRegexSource, dateRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, ZodReadonly, late, ZodFirstPartyTypeKind, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType, coerce;
3636
3606
  var init_lib = __esm({
3637
- "../node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.mjs"() {
3607
+ "../node_modules/.pnpm/zod@3.23.7/node_modules/zod/lib/index.mjs"() {
3638
3608
  "use strict";
3639
3609
  (function(util2) {
3640
3610
  util2.assertEqual = (val) => val;
@@ -3784,9 +3754,6 @@ var init_lib = __esm({
3784
3754
  "not_finite"
3785
3755
  ]);
3786
3756
  ZodError = class _ZodError extends Error {
3787
- get errors() {
3788
- return this.issues;
3789
- }
3790
3757
  constructor(issues) {
3791
3758
  super();
3792
3759
  this.issues = [];
@@ -3805,6 +3772,9 @@ var init_lib = __esm({
3805
3772
  this.name = "ZodError";
3806
3773
  this.issues = issues;
3807
3774
  }
3775
+ get errors() {
3776
+ return this.issues;
3777
+ }
3808
3778
  format(_mapper) {
3809
3779
  const mapper = _mapper || function(issue) {
3810
3780
  return issue.message;
@@ -4106,6 +4076,34 @@ var init_lib = __esm({
4106
4076
  }
4107
4077
  };
4108
4078
  ZodType = class {
4079
+ constructor(def) {
4080
+ this.spa = this.safeParseAsync;
4081
+ this._def = def;
4082
+ this.parse = this.parse.bind(this);
4083
+ this.safeParse = this.safeParse.bind(this);
4084
+ this.parseAsync = this.parseAsync.bind(this);
4085
+ this.safeParseAsync = this.safeParseAsync.bind(this);
4086
+ this.spa = this.spa.bind(this);
4087
+ this.refine = this.refine.bind(this);
4088
+ this.refinement = this.refinement.bind(this);
4089
+ this.superRefine = this.superRefine.bind(this);
4090
+ this.optional = this.optional.bind(this);
4091
+ this.nullable = this.nullable.bind(this);
4092
+ this.nullish = this.nullish.bind(this);
4093
+ this.array = this.array.bind(this);
4094
+ this.promise = this.promise.bind(this);
4095
+ this.or = this.or.bind(this);
4096
+ this.and = this.and.bind(this);
4097
+ this.transform = this.transform.bind(this);
4098
+ this.brand = this.brand.bind(this);
4099
+ this.default = this.default.bind(this);
4100
+ this.catch = this.catch.bind(this);
4101
+ this.describe = this.describe.bind(this);
4102
+ this.pipe = this.pipe.bind(this);
4103
+ this.readonly = this.readonly.bind(this);
4104
+ this.isNullable = this.isNullable.bind(this);
4105
+ this.isOptional = this.isOptional.bind(this);
4106
+ }
4109
4107
  get description() {
4110
4108
  return this._def.description;
4111
4109
  }
@@ -4169,43 +4167,6 @@ var init_lib = __esm({
4169
4167
  const result = this._parseSync({ data, path: ctx.path, parent: ctx });
4170
4168
  return handleResult(ctx, result);
4171
4169
  }
4172
- "~validate"(data) {
4173
- var _a435, _b325;
4174
- const ctx = {
4175
- common: {
4176
- issues: [],
4177
- async: !!this["~standard"].async
4178
- },
4179
- path: [],
4180
- schemaErrorMap: this._def.errorMap,
4181
- parent: null,
4182
- data,
4183
- parsedType: getParsedType(data)
4184
- };
4185
- if (!this["~standard"].async) {
4186
- try {
4187
- const result = this._parseSync({ data, path: [], parent: ctx });
4188
- return isValid(result) ? {
4189
- value: result.value
4190
- } : {
4191
- issues: ctx.common.issues
4192
- };
4193
- } catch (err) {
4194
- if ((_b325 = (_a435 = err === null || err === void 0 ? void 0 : err.message) === null || _a435 === void 0 ? void 0 : _a435.toLowerCase()) === null || _b325 === void 0 ? void 0 : _b325.includes("encountered")) {
4195
- this["~standard"].async = true;
4196
- }
4197
- ctx.common = {
4198
- issues: [],
4199
- async: true
4200
- };
4201
- }
4202
- }
4203
- return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
4204
- value: result.value
4205
- } : {
4206
- issues: ctx.common.issues
4207
- });
4208
- }
4209
4170
  async parseAsync(data, params) {
4210
4171
  const result = await this.safeParseAsync(data, params);
4211
4172
  if (result.success)
@@ -4283,39 +4244,6 @@ var init_lib = __esm({
4283
4244
  superRefine(refinement) {
4284
4245
  return this._refinement(refinement);
4285
4246
  }
4286
- constructor(def) {
4287
- this.spa = this.safeParseAsync;
4288
- this._def = def;
4289
- this.parse = this.parse.bind(this);
4290
- this.safeParse = this.safeParse.bind(this);
4291
- this.parseAsync = this.parseAsync.bind(this);
4292
- this.safeParseAsync = this.safeParseAsync.bind(this);
4293
- this.spa = this.spa.bind(this);
4294
- this.refine = this.refine.bind(this);
4295
- this.refinement = this.refinement.bind(this);
4296
- this.superRefine = this.superRefine.bind(this);
4297
- this.optional = this.optional.bind(this);
4298
- this.nullable = this.nullable.bind(this);
4299
- this.nullish = this.nullish.bind(this);
4300
- this.array = this.array.bind(this);
4301
- this.promise = this.promise.bind(this);
4302
- this.or = this.or.bind(this);
4303
- this.and = this.and.bind(this);
4304
- this.transform = this.transform.bind(this);
4305
- this.brand = this.brand.bind(this);
4306
- this.default = this.default.bind(this);
4307
- this.catch = this.catch.bind(this);
4308
- this.describe = this.describe.bind(this);
4309
- this.pipe = this.pipe.bind(this);
4310
- this.readonly = this.readonly.bind(this);
4311
- this.isNullable = this.isNullable.bind(this);
4312
- this.isOptional = this.isOptional.bind(this);
4313
- this["~standard"] = {
4314
- version: 1,
4315
- vendor: "zod",
4316
- validate: (data) => this["~validate"](data)
4317
- };
4318
- }
4319
4247
  optional() {
4320
4248
  return ZodOptional.create(this, this._def);
4321
4249
  }
@@ -4326,7 +4254,7 @@ var init_lib = __esm({
4326
4254
  return this.nullable().optional();
4327
4255
  }
4328
4256
  array() {
4329
- return ZodArray.create(this);
4257
+ return ZodArray.create(this, this._def);
4330
4258
  }
4331
4259
  promise() {
4332
4260
  return ZodPromise.create(this, this._def);
@@ -4392,19 +4320,15 @@ var init_lib = __esm({
4392
4320
  };
4393
4321
  cuidRegex = /^c[^\s-]{8,}$/i;
4394
4322
  cuid2Regex = /^[0-9a-z]+$/;
4395
- ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
4323
+ ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
4396
4324
  uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
4397
4325
  nanoidRegex = /^[a-z0-9_-]{21}$/i;
4398
- jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
4399
4326
  durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
4400
4327
  emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
4401
4328
  _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
4402
4329
  ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
4403
- ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
4404
- ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
4405
- ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
4330
+ ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
4406
4331
  base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
4407
- base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
4408
4332
  dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
4409
4333
  dateRegex = new RegExp(`^${dateRegexSource}$`);
4410
4334
  ZodString = class _ZodString extends ZodType {
@@ -4663,26 +4587,6 @@ var init_lib = __esm({
4663
4587
  });
4664
4588
  status.dirty();
4665
4589
  }
4666
- } else if (check.kind === "jwt") {
4667
- if (!isValidJWT(input.data, check.alg)) {
4668
- ctx = this._getOrReturnCtx(input, ctx);
4669
- addIssueToContext(ctx, {
4670
- validation: "jwt",
4671
- code: ZodIssueCode.invalid_string,
4672
- message: check.message
4673
- });
4674
- status.dirty();
4675
- }
4676
- } else if (check.kind === "cidr") {
4677
- if (!isValidCidr(input.data, check.version)) {
4678
- ctx = this._getOrReturnCtx(input, ctx);
4679
- addIssueToContext(ctx, {
4680
- validation: "cidr",
4681
- code: ZodIssueCode.invalid_string,
4682
- message: check.message
4683
- });
4684
- status.dirty();
4685
- }
4686
4590
  } else if (check.kind === "base64") {
4687
4591
  if (!base64Regex.test(input.data)) {
4688
4592
  ctx = this._getOrReturnCtx(input, ctx);
@@ -4693,16 +4597,6 @@ var init_lib = __esm({
4693
4597
  });
4694
4598
  status.dirty();
4695
4599
  }
4696
- } else if (check.kind === "base64url") {
4697
- if (!base64urlRegex.test(input.data)) {
4698
- ctx = this._getOrReturnCtx(input, ctx);
4699
- addIssueToContext(ctx, {
4700
- validation: "base64url",
4701
- code: ZodIssueCode.invalid_string,
4702
- message: check.message
4703
- });
4704
- status.dirty();
4705
- }
4706
4600
  } else {
4707
4601
  util.assertNever(check);
4708
4602
  }
@@ -4749,21 +4643,9 @@ var init_lib = __esm({
4749
4643
  base64(message) {
4750
4644
  return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
4751
4645
  }
4752
- base64url(message) {
4753
- return this._addCheck({
4754
- kind: "base64url",
4755
- ...errorUtil.errToObj(message)
4756
- });
4757
- }
4758
- jwt(options) {
4759
- return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
4760
- }
4761
4646
  ip(options) {
4762
4647
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
4763
4648
  }
4764
- cidr(options) {
4765
- return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
4766
- }
4767
4649
  datetime(options) {
4768
4650
  var _a435, _b325;
4769
4651
  if (typeof options === "string") {
@@ -4854,7 +4736,8 @@ var init_lib = __esm({
4854
4736
  });
4855
4737
  }
4856
4738
  /**
4857
- * Equivalent to `.min(1)`
4739
+ * @deprecated Use z.string().min(1) instead.
4740
+ * @see {@link ZodString.min}
4858
4741
  */
4859
4742
  nonempty(message) {
4860
4743
  return this.min(1, errorUtil.errToObj(message));
@@ -4916,15 +4799,9 @@ var init_lib = __esm({
4916
4799
  get isIP() {
4917
4800
  return !!this._def.checks.find((ch) => ch.kind === "ip");
4918
4801
  }
4919
- get isCIDR() {
4920
- return !!this._def.checks.find((ch) => ch.kind === "cidr");
4921
- }
4922
4802
  get isBase64() {
4923
4803
  return !!this._def.checks.find((ch) => ch.kind === "base64");
4924
4804
  }
4925
- get isBase64url() {
4926
- return !!this._def.checks.find((ch) => ch.kind === "base64url");
4927
- }
4928
4805
  get minLength() {
4929
4806
  let min2 = null;
4930
4807
  for (const ch of this._def.checks) {
@@ -5194,15 +5071,17 @@ var init_lib = __esm({
5194
5071
  }
5195
5072
  _parse(input) {
5196
5073
  if (this._def.coerce) {
5197
- try {
5198
- input.data = BigInt(input.data);
5199
- } catch (_a435) {
5200
- return this._getInvalidInput(input);
5201
- }
5074
+ input.data = BigInt(input.data);
5202
5075
  }
5203
5076
  const parsedType = this._getType(input);
5204
5077
  if (parsedType !== ZodParsedType.bigint) {
5205
- return this._getInvalidInput(input);
5078
+ const ctx2 = this._getOrReturnCtx(input);
5079
+ addIssueToContext(ctx2, {
5080
+ code: ZodIssueCode.invalid_type,
5081
+ expected: ZodParsedType.bigint,
5082
+ received: ctx2.parsedType
5083
+ });
5084
+ return INVALID;
5206
5085
  }
5207
5086
  let ctx = void 0;
5208
5087
  const status = new ParseStatus();
@@ -5249,15 +5128,6 @@ var init_lib = __esm({
5249
5128
  }
5250
5129
  return { status: status.value, value: input.data };
5251
5130
  }
5252
- _getInvalidInput(input) {
5253
- const ctx = this._getOrReturnCtx(input);
5254
- addIssueToContext(ctx, {
5255
- code: ZodIssueCode.invalid_type,
5256
- expected: ZodParsedType.bigint,
5257
- received: ctx.parsedType
5258
- });
5259
- return INVALID;
5260
- }
5261
5131
  gte(value, message) {
5262
5132
  return this.setLimit("min", value, true, errorUtil.toString(message));
5263
5133
  }
@@ -22096,8 +21966,7 @@ var init_column_builder = __esm({
22096
21966
  }
22097
21967
  /** @internal Sets the name of the column to the key within the table definition if a name was not given. */
22098
21968
  setName(name2) {
22099
- if (this.config.name !== "")
22100
- return;
21969
+ if (this.config.name !== "") return;
22101
21970
  this.config.name = name2;
22102
21971
  }
22103
21972
  };
@@ -22529,8 +22398,7 @@ var init_common2 = __esm({
22529
22398
  const a = value.map(
22530
22399
  (v) => v === null ? null : is(this.baseColumn, _PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v)
22531
22400
  );
22532
- if (isNestedArray)
22533
- return a;
22401
+ if (isNestedArray) return a;
22534
22402
  return makePgArray(a);
22535
22403
  }
22536
22404
  };
@@ -22662,7 +22530,7 @@ var version;
22662
22530
  var init_version = __esm({
22663
22531
  "../drizzle-orm/dist/version.js"() {
22664
22532
  "use strict";
22665
- version = "0.42.0";
22533
+ version = "0.43.1";
22666
22534
  }
22667
22535
  });
22668
22536
 
@@ -23522,8 +23390,7 @@ function mapUpdateSet(table6, values) {
23522
23390
  function applyMixins(baseClass, extendedClasses) {
23523
23391
  for (const extendedClass of extendedClasses) {
23524
23392
  for (const name2 of Object.getOwnPropertyNames(extendedClass.prototype)) {
23525
- if (name2 === "constructor")
23526
- continue;
23393
+ if (name2 === "constructor") continue;
23527
23394
  Object.defineProperty(
23528
23395
  baseClass.prototype,
23529
23396
  name2,
@@ -23548,47 +23415,38 @@ function getColumnNameAndConfig(a, b) {
23548
23415
  };
23549
23416
  }
23550
23417
  function isConfig(data) {
23551
- if (typeof data !== "object" || data === null)
23552
- return false;
23553
- if (data.constructor.name !== "Object")
23554
- return false;
23418
+ if (typeof data !== "object" || data === null) return false;
23419
+ if (data.constructor.name !== "Object") return false;
23555
23420
  if ("logger" in data) {
23556
23421
  const type = typeof data["logger"];
23557
- if (type !== "boolean" && (type !== "object" || typeof data["logger"]["logQuery"] !== "function") && type !== "undefined")
23558
- return false;
23422
+ if (type !== "boolean" && (type !== "object" || typeof data["logger"]["logQuery"] !== "function") && type !== "undefined") return false;
23559
23423
  return true;
23560
23424
  }
23561
23425
  if ("schema" in data) {
23562
23426
  const type = typeof data["schema"];
23563
- if (type !== "object" && type !== "undefined")
23564
- return false;
23427
+ if (type !== "object" && type !== "undefined") return false;
23565
23428
  return true;
23566
23429
  }
23567
23430
  if ("casing" in data) {
23568
23431
  const type = typeof data["casing"];
23569
- if (type !== "string" && type !== "undefined")
23570
- return false;
23432
+ if (type !== "string" && type !== "undefined") return false;
23571
23433
  return true;
23572
23434
  }
23573
23435
  if ("mode" in data) {
23574
- if (data["mode"] !== "default" || data["mode"] !== "planetscale" || data["mode"] !== void 0)
23575
- return false;
23436
+ if (data["mode"] !== "default" || data["mode"] !== "planetscale" || data["mode"] !== void 0) return false;
23576
23437
  return true;
23577
23438
  }
23578
23439
  if ("connection" in data) {
23579
23440
  const type = typeof data["connection"];
23580
- if (type !== "string" && type !== "object" && type !== "undefined")
23581
- return false;
23441
+ if (type !== "string" && type !== "object" && type !== "undefined") return false;
23582
23442
  return true;
23583
23443
  }
23584
23444
  if ("client" in data) {
23585
23445
  const type = typeof data["client"];
23586
- if (type !== "object" && type !== "function" && type !== "undefined")
23587
- return false;
23446
+ if (type !== "object" && type !== "function" && type !== "undefined") return false;
23588
23447
  return true;
23589
23448
  }
23590
- if (Object.keys(data).length === 0)
23591
- return true;
23449
+ if (Object.keys(data).length === 0) return true;
23592
23450
  return false;
23593
23451
  }
23594
23452
  var init_utils2 = __esm({
@@ -24406,8 +24264,7 @@ var init_numeric = __esm({
24406
24264
  this.scale = config.scale;
24407
24265
  }
24408
24266
  mapFromDriverValue(value) {
24409
- if (typeof value === "string")
24410
- return value;
24267
+ if (typeof value === "string") return value;
24411
24268
  return String(value);
24412
24269
  }
24413
24270
  getSQLType() {
@@ -24446,8 +24303,7 @@ var init_numeric = __esm({
24446
24303
  this.scale = config.scale;
24447
24304
  }
24448
24305
  mapFromDriverValue(value) {
24449
- if (typeof value === "number")
24450
- return value;
24306
+ if (typeof value === "number") return value;
24451
24307
  return Number(value);
24452
24308
  }
24453
24309
  getSQLType() {
@@ -26426,8 +26282,7 @@ var init_casing = __esm({
26426
26282
  this.convert = casing2 === "snake_case" ? toSnakeCase : casing2 === "camelCase" ? toCamelCase : noopCase;
26427
26283
  }
26428
26284
  getColumnCasing(column6) {
26429
- if (!column6.keyAsName)
26430
- return column6.name;
26285
+ if (!column6.keyAsName) return column6.name;
26431
26286
  const schema5 = column6.table[Table2.Symbol.Schema] ?? "public";
26432
26287
  const tableName = column6.table[Table2.Symbol.OriginalName];
26433
26288
  const key = `${schema5}.${tableName}.${column6.name}`;
@@ -26536,8 +26391,7 @@ var init_dialect = __esm({
26536
26391
  return `'${str.replace(/'/g, "''")}'`;
26537
26392
  }
26538
26393
  buildWithCTE(queries) {
26539
- if (!queries?.length)
26540
- return void 0;
26394
+ if (!queries?.length) return void 0;
26541
26395
  const withSqlChunks = [sql`with `];
26542
26396
  for (const [i, w] of queries.entries()) {
26543
26397
  withSqlChunks.push(sql`${sql.identifier(w._.alias)} as (${w._.sql})`);
@@ -26645,13 +26499,14 @@ var init_dialect = __esm({
26645
26499
  }
26646
26500
  const table6 = joinMeta.table;
26647
26501
  const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
26502
+ const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
26648
26503
  if (is(table6, PgTable)) {
26649
26504
  const tableName = table6[PgTable.Symbol.Name];
26650
26505
  const tableSchema = table6[PgTable.Symbol.Schema];
26651
26506
  const origTableName = table6[PgTable.Symbol.OriginalName];
26652
26507
  const alias = tableName === origTableName ? void 0 : joinMeta.alias;
26653
26508
  joinsArray.push(
26654
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
26509
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
26655
26510
  );
26656
26511
  } else if (is(table6, View3)) {
26657
26512
  const viewName = table6[ViewBaseConfig].name;
@@ -26659,11 +26514,11 @@ var init_dialect = __esm({
26659
26514
  const origViewName = table6[ViewBaseConfig].originalName;
26660
26515
  const alias = viewName === origViewName ? void 0 : joinMeta.alias;
26661
26516
  joinsArray.push(
26662
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
26517
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
26663
26518
  );
26664
26519
  } else {
26665
26520
  joinsArray.push(
26666
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table6} on ${joinMeta.on}`
26521
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table6}${onSql}`
26667
26522
  );
26668
26523
  }
26669
26524
  if (index6 < joins.length - 1) {
@@ -26742,7 +26597,7 @@ var init_dialect = __esm({
26742
26597
  );
26743
26598
  }
26744
26599
  if (lockingClause.config.noWait) {
26745
- clauseSql.append(sql` no wait`);
26600
+ clauseSql.append(sql` nowait`);
26746
26601
  } else if (lockingClause.config.skipLocked) {
26747
26602
  clauseSql.append(sql` skip locked`);
26748
26603
  }
@@ -27718,12 +27573,12 @@ var init_select2 = __esm({
27718
27573
  *
27719
27574
  * ```ts
27720
27575
  * // Select all users and their pets
27721
- * const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
27576
+ * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
27722
27577
  * .from(users)
27723
27578
  * .leftJoin(pets, eq(users.id, pets.ownerId))
27724
27579
  *
27725
27580
  * // Select userId and petId
27726
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
27581
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
27727
27582
  * userId: users.id,
27728
27583
  * petId: pets.id,
27729
27584
  * })
@@ -27731,7 +27586,20 @@ var init_select2 = __esm({
27731
27586
  * .leftJoin(pets, eq(users.id, pets.ownerId))
27732
27587
  * ```
27733
27588
  */
27734
- __publicField(this, "leftJoin", this.createJoin("left"));
27589
+ __publicField(this, "leftJoin", this.createJoin("left", false));
27590
+ /**
27591
+ * Executes a `left join lateral` operation by adding subquery to the current query.
27592
+ *
27593
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
27594
+ *
27595
+ * Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.
27596
+ *
27597
+ * See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
27598
+ *
27599
+ * @param table the subquery to join.
27600
+ * @param on the `on` clause.
27601
+ */
27602
+ __publicField(this, "leftJoinLateral", this.createJoin("left", true));
27735
27603
  /**
27736
27604
  * Executes a `right join` operation by adding another table to the current query.
27737
27605
  *
@@ -27746,12 +27614,12 @@ var init_select2 = __esm({
27746
27614
  *
27747
27615
  * ```ts
27748
27616
  * // Select all users and their pets
27749
- * const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
27617
+ * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
27750
27618
  * .from(users)
27751
27619
  * .rightJoin(pets, eq(users.id, pets.ownerId))
27752
27620
  *
27753
27621
  * // Select userId and petId
27754
- * const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
27622
+ * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
27755
27623
  * userId: users.id,
27756
27624
  * petId: pets.id,
27757
27625
  * })
@@ -27759,7 +27627,7 @@ var init_select2 = __esm({
27759
27627
  * .rightJoin(pets, eq(users.id, pets.ownerId))
27760
27628
  * ```
27761
27629
  */
27762
- __publicField(this, "rightJoin", this.createJoin("right"));
27630
+ __publicField(this, "rightJoin", this.createJoin("right", false));
27763
27631
  /**
27764
27632
  * Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
27765
27633
  *
@@ -27774,12 +27642,12 @@ var init_select2 = __esm({
27774
27642
  *
27775
27643
  * ```ts
27776
27644
  * // Select all users and their pets
27777
- * const usersWithPets: { user: User; pets: Pet }[] = await db.select()
27645
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
27778
27646
  * .from(users)
27779
27647
  * .innerJoin(pets, eq(users.id, pets.ownerId))
27780
27648
  *
27781
27649
  * // Select userId and petId
27782
- * const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
27650
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
27783
27651
  * userId: users.id,
27784
27652
  * petId: pets.id,
27785
27653
  * })
@@ -27787,7 +27655,20 @@ var init_select2 = __esm({
27787
27655
  * .innerJoin(pets, eq(users.id, pets.ownerId))
27788
27656
  * ```
27789
27657
  */
27790
- __publicField(this, "innerJoin", this.createJoin("inner"));
27658
+ __publicField(this, "innerJoin", this.createJoin("inner", false));
27659
+ /**
27660
+ * Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
27661
+ *
27662
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
27663
+ *
27664
+ * Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.
27665
+ *
27666
+ * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
27667
+ *
27668
+ * @param table the subquery to join.
27669
+ * @param on the `on` clause.
27670
+ */
27671
+ __publicField(this, "innerJoinLateral", this.createJoin("inner", true));
27791
27672
  /**
27792
27673
  * Executes a `full join` operation by combining rows from two tables into a new table.
27793
27674
  *
@@ -27802,12 +27683,12 @@ var init_select2 = __esm({
27802
27683
  *
27803
27684
  * ```ts
27804
27685
  * // Select all users and their pets
27805
- * const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
27686
+ * const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
27806
27687
  * .from(users)
27807
27688
  * .fullJoin(pets, eq(users.id, pets.ownerId))
27808
27689
  *
27809
27690
  * // Select userId and petId
27810
- * const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
27691
+ * const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
27811
27692
  * userId: users.id,
27812
27693
  * petId: pets.id,
27813
27694
  * })
@@ -27815,7 +27696,46 @@ var init_select2 = __esm({
27815
27696
  * .fullJoin(pets, eq(users.id, pets.ownerId))
27816
27697
  * ```
27817
27698
  */
27818
- __publicField(this, "fullJoin", this.createJoin("full"));
27699
+ __publicField(this, "fullJoin", this.createJoin("full", false));
27700
+ /**
27701
+ * Executes a `cross join` operation by combining rows from two tables into a new table.
27702
+ *
27703
+ * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
27704
+ *
27705
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
27706
+ *
27707
+ * @param table the table to join.
27708
+ *
27709
+ * @example
27710
+ *
27711
+ * ```ts
27712
+ * // Select all users, each user with every pet
27713
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
27714
+ * .from(users)
27715
+ * .crossJoin(pets)
27716
+ *
27717
+ * // Select userId and petId
27718
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
27719
+ * userId: users.id,
27720
+ * petId: pets.id,
27721
+ * })
27722
+ * .from(users)
27723
+ * .crossJoin(pets)
27724
+ * ```
27725
+ */
27726
+ __publicField(this, "crossJoin", this.createJoin("cross", false));
27727
+ /**
27728
+ * Executes a `cross join lateral` operation by combining rows from two queries into a new table.
27729
+ *
27730
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
27731
+ *
27732
+ * Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
27733
+ *
27734
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
27735
+ *
27736
+ * @param table the query to join.
27737
+ */
27738
+ __publicField(this, "crossJoinLateral", this.createJoin("cross", true));
27819
27739
  /**
27820
27740
  * Adds `union` set operator to the query.
27821
27741
  *
@@ -28018,7 +27938,7 @@ var init_select2 = __esm({
28018
27938
  this.tableName = getTableLikeName(table6);
28019
27939
  this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
28020
27940
  }
28021
- createJoin(joinType) {
27941
+ createJoin(joinType, lateral) {
28022
27942
  return (table6, on) => {
28023
27943
  const baseTableName = this.tableName;
28024
27944
  const tableName = getTableLikeName(table6);
@@ -28047,7 +27967,7 @@ var init_select2 = __esm({
28047
27967
  if (!this.config.joins) {
28048
27968
  this.config.joins = [];
28049
27969
  }
28050
- this.config.joins.push({ on, table: table6, joinType, alias: tableName });
27970
+ this.config.joins.push({ on, table: table6, joinType, alias: tableName, lateral });
28051
27971
  if (typeof tableName === "string") {
28052
27972
  switch (joinType) {
28053
27973
  case "left": {
@@ -28061,6 +27981,7 @@ var init_select2 = __esm({
28061
27981
  this.joinsNotNullableMap[tableName] = true;
28062
27982
  break;
28063
27983
  }
27984
+ case "cross":
28064
27985
  case "inner": {
28065
27986
  this.joinsNotNullableMap[tableName] = true;
28066
27987
  break;
@@ -29976,18 +29897,18 @@ var init_schema = __esm({
29976
29897
  __publicField(this, "materializedView", (name2, columns) => {
29977
29898
  return pgMaterializedViewWithSchema(name2, columns, this.schemaName);
29978
29899
  });
29979
- __publicField(this, "enum", (enumName, input) => {
29980
- return Array.isArray(input) ? pgEnumWithSchema(
29981
- enumName,
29982
- [...input],
29983
- this.schemaName
29984
- ) : pgEnumObjectWithSchema(enumName, input, this.schemaName);
29985
- });
29986
29900
  __publicField(this, "sequence", (name2, options) => {
29987
29901
  return pgSequenceWithSchema(name2, options, this.schemaName);
29988
29902
  });
29989
29903
  this.schemaName = schemaName;
29990
29904
  }
29905
+ enum(enumName, input) {
29906
+ return Array.isArray(input) ? pgEnumWithSchema(
29907
+ enumName,
29908
+ [...input],
29909
+ this.schemaName
29910
+ ) : pgEnumObjectWithSchema(enumName, input, this.schemaName);
29911
+ }
29991
29912
  getSQL() {
29992
29913
  return new SQL([sql.identifier(this.schemaName)]);
29993
29914
  }
@@ -32438,8 +32359,7 @@ var init_numeric2 = __esm({
32438
32359
  __publicField(SQLiteNumericBuilder, _a193, "SQLiteNumericBuilder");
32439
32360
  SQLiteNumeric = class extends (_b139 = SQLiteColumn, _a194 = entityKind, _b139) {
32440
32361
  mapFromDriverValue(value) {
32441
- if (typeof value === "string")
32442
- return value;
32362
+ if (typeof value === "string") return value;
32443
32363
  return String(value);
32444
32364
  }
32445
32365
  getSQLType() {
@@ -32466,8 +32386,7 @@ var init_numeric2 = __esm({
32466
32386
  __publicField(this, "mapToDriverValue", String);
32467
32387
  }
32468
32388
  mapFromDriverValue(value) {
32469
- if (typeof value === "number")
32470
- return value;
32389
+ if (typeof value === "number") return value;
32471
32390
  return Number(value);
32472
32391
  }
32473
32392
  getSQLType() {
@@ -32859,8 +32778,7 @@ var init_dialect2 = __esm({
32859
32778
  return `'${str.replace(/'/g, "''")}'`;
32860
32779
  }
32861
32780
  buildWithCTE(queries) {
32862
- if (!queries?.length)
32863
- return void 0;
32781
+ if (!queries?.length) return void 0;
32864
32782
  const withSqlChunks = [sql`with `];
32865
32783
  for (const [i, w] of queries.entries()) {
32866
32784
  withSqlChunks.push(sql`${sql.identifier(w._.alias)} as (${w._.sql})`);
@@ -32978,17 +32896,18 @@ var init_dialect2 = __esm({
32978
32896
  joinsArray.push(sql` `);
32979
32897
  }
32980
32898
  const table6 = joinMeta.table;
32899
+ const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
32981
32900
  if (is(table6, SQLiteTable)) {
32982
32901
  const tableName = table6[SQLiteTable.Symbol.Name];
32983
32902
  const tableSchema = table6[SQLiteTable.Symbol.Schema];
32984
32903
  const origTableName = table6[SQLiteTable.Symbol.OriginalName];
32985
32904
  const alias = tableName === origTableName ? void 0 : joinMeta.alias;
32986
32905
  joinsArray.push(
32987
- sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
32906
+ sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
32988
32907
  );
32989
32908
  } else {
32990
32909
  joinsArray.push(
32991
- sql`${sql.raw(joinMeta.joinType)} join ${table6} on ${joinMeta.on}`
32910
+ sql`${sql.raw(joinMeta.joinType)} join ${table6}${onSql}`
32992
32911
  );
32993
32912
  }
32994
32913
  if (index6 < joins.length - 1) {
@@ -33562,12 +33481,12 @@ var init_select3 = __esm({
33562
33481
  *
33563
33482
  * ```ts
33564
33483
  * // Select all users and their pets
33565
- * const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
33484
+ * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
33566
33485
  * .from(users)
33567
33486
  * .leftJoin(pets, eq(users.id, pets.ownerId))
33568
33487
  *
33569
33488
  * // Select userId and petId
33570
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
33489
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
33571
33490
  * userId: users.id,
33572
33491
  * petId: pets.id,
33573
33492
  * })
@@ -33590,12 +33509,12 @@ var init_select3 = __esm({
33590
33509
  *
33591
33510
  * ```ts
33592
33511
  * // Select all users and their pets
33593
- * const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
33512
+ * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
33594
33513
  * .from(users)
33595
33514
  * .rightJoin(pets, eq(users.id, pets.ownerId))
33596
33515
  *
33597
33516
  * // Select userId and petId
33598
- * const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
33517
+ * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
33599
33518
  * userId: users.id,
33600
33519
  * petId: pets.id,
33601
33520
  * })
@@ -33618,12 +33537,12 @@ var init_select3 = __esm({
33618
33537
  *
33619
33538
  * ```ts
33620
33539
  * // Select all users and their pets
33621
- * const usersWithPets: { user: User; pets: Pet }[] = await db.select()
33540
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
33622
33541
  * .from(users)
33623
33542
  * .innerJoin(pets, eq(users.id, pets.ownerId))
33624
33543
  *
33625
33544
  * // Select userId and petId
33626
- * const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
33545
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
33627
33546
  * userId: users.id,
33628
33547
  * petId: pets.id,
33629
33548
  * })
@@ -33646,12 +33565,12 @@ var init_select3 = __esm({
33646
33565
  *
33647
33566
  * ```ts
33648
33567
  * // Select all users and their pets
33649
- * const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
33568
+ * const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
33650
33569
  * .from(users)
33651
33570
  * .fullJoin(pets, eq(users.id, pets.ownerId))
33652
33571
  *
33653
33572
  * // Select userId and petId
33654
- * const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
33573
+ * const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
33655
33574
  * userId: users.id,
33656
33575
  * petId: pets.id,
33657
33576
  * })
@@ -33660,6 +33579,33 @@ var init_select3 = __esm({
33660
33579
  * ```
33661
33580
  */
33662
33581
  __publicField(this, "fullJoin", this.createJoin("full"));
33582
+ /**
33583
+ * Executes a `cross join` operation by combining rows from two tables into a new table.
33584
+ *
33585
+ * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
33586
+ *
33587
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
33588
+ *
33589
+ * @param table the table to join.
33590
+ *
33591
+ * @example
33592
+ *
33593
+ * ```ts
33594
+ * // Select all users, each user with every pet
33595
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
33596
+ * .from(users)
33597
+ * .crossJoin(pets)
33598
+ *
33599
+ * // Select userId and petId
33600
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
33601
+ * userId: users.id,
33602
+ * petId: pets.id,
33603
+ * })
33604
+ * .from(users)
33605
+ * .crossJoin(pets)
33606
+ * ```
33607
+ */
33608
+ __publicField(this, "crossJoin", this.createJoin("cross"));
33663
33609
  /**
33664
33610
  * Adds `union` set operator to the query.
33665
33611
  *
@@ -33823,6 +33769,7 @@ var init_select3 = __esm({
33823
33769
  this.joinsNotNullableMap[tableName] = true;
33824
33770
  break;
33825
33771
  }
33772
+ case "cross":
33826
33773
  case "inner": {
33827
33774
  this.joinsNotNullableMap[tableName] = true;
33828
33775
  break;
@@ -34271,8 +34218,7 @@ var init_insert2 = __esm({
34271
34218
  * ```
34272
34219
  */
34273
34220
  onConflictDoNothing(config = {}) {
34274
- if (!this.config.onConflict)
34275
- this.config.onConflict = [];
34221
+ if (!this.config.onConflict) this.config.onConflict = [];
34276
34222
  if (config.target === void 0) {
34277
34223
  this.config.onConflict.push(sql` on conflict do nothing`);
34278
34224
  } else {
@@ -34317,8 +34263,7 @@ var init_insert2 = __esm({
34317
34263
  'You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.'
34318
34264
  );
34319
34265
  }
34320
- if (!this.config.onConflict)
34321
- this.config.onConflict = [];
34266
+ if (!this.config.onConflict) this.config.onConflict = [];
34322
34267
  const whereSql = config.where ? sql` where ${config.where}` : void 0;
34323
34268
  const targetWhereSql = config.targetWhere ? sql` where ${config.targetWhere}` : void 0;
34324
34269
  const setWhereSql = config.setWhere ? sql` where ${config.setWhere}` : void 0;
@@ -36547,10 +36492,8 @@ var init_binary = __esm({
36547
36492
  __publicField(this, "length", this.config.length);
36548
36493
  }
36549
36494
  mapFromDriverValue(value) {
36550
- if (typeof value === "string")
36551
- return value;
36552
- if (Buffer.isBuffer(value))
36553
- return value.toString();
36495
+ if (typeof value === "string") return value;
36496
+ if (Buffer.isBuffer(value)) return value.toString();
36554
36497
  const str = [];
36555
36498
  for (const v of value) {
36556
36499
  str.push(v === 49 ? "1" : "0");
@@ -36872,8 +36815,7 @@ var init_decimal = __esm({
36872
36815
  __publicField(this, "unsigned", this.config.unsigned);
36873
36816
  }
36874
36817
  mapFromDriverValue(value) {
36875
- if (typeof value === "string")
36876
- return value;
36818
+ if (typeof value === "string") return value;
36877
36819
  return String(value);
36878
36820
  }
36879
36821
  getSQLType() {
@@ -36915,8 +36857,7 @@ var init_decimal = __esm({
36915
36857
  __publicField(this, "mapToDriverValue", String);
36916
36858
  }
36917
36859
  mapFromDriverValue(value) {
36918
- if (typeof value === "number")
36919
- return value;
36860
+ if (typeof value === "number") return value;
36920
36861
  return Number(value);
36921
36862
  }
36922
36863
  getSQLType() {
@@ -37645,10 +37586,8 @@ var init_varbinary = __esm({
37645
37586
  __publicField(this, "length", this.config.length);
37646
37587
  }
37647
37588
  mapFromDriverValue(value) {
37648
- if (typeof value === "string")
37649
- return value;
37650
- if (Buffer.isBuffer(value))
37651
- return value.toString();
37589
+ if (typeof value === "string") return value;
37590
+ if (Buffer.isBuffer(value)) return value.toString();
37652
37591
  const str = [];
37653
37592
  for (const v of value) {
37654
37593
  str.push(v === 49 ? "1" : "0");
@@ -38113,8 +38052,7 @@ var init_dialect3 = __esm({
38113
38052
  return `'${str.replace(/'/g, "''")}'`;
38114
38053
  }
38115
38054
  buildWithCTE(queries) {
38116
- if (!queries?.length)
38117
- return void 0;
38055
+ if (!queries?.length) return void 0;
38118
38056
  const withSqlChunks = [sql`with `];
38119
38057
  for (const [i, w] of queries.entries()) {
38120
38058
  withSqlChunks.push(sql`${sql.identifier(w._.alias)} as (${w._.sql})`);
@@ -38268,6 +38206,7 @@ var init_dialect3 = __esm({
38268
38206
  }
38269
38207
  const table22 = joinMeta.table;
38270
38208
  const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
38209
+ const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
38271
38210
  if (is(table22, MySqlTable)) {
38272
38211
  const tableName = table22[MySqlTable.Symbol.Name];
38273
38212
  const tableSchema = table22[MySqlTable.Symbol.Schema];
@@ -38277,7 +38216,7 @@ var init_dialect3 = __esm({
38277
38216
  const forceIndexSql2 = this.buildIndex({ indexes: joinMeta.forceIndex, indexFor: "FORCE" });
38278
38217
  const ignoreIndexSql2 = this.buildIndex({ indexes: joinMeta.ignoreIndex, indexFor: "IGNORE" });
38279
38218
  joinsArray.push(
38280
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${useIndexSql2}${forceIndexSql2}${ignoreIndexSql2}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
38219
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${useIndexSql2}${forceIndexSql2}${ignoreIndexSql2}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
38281
38220
  );
38282
38221
  } else if (is(table22, View3)) {
38283
38222
  const viewName = table22[ViewBaseConfig].name;
@@ -38285,11 +38224,11 @@ var init_dialect3 = __esm({
38285
38224
  const origViewName = table22[ViewBaseConfig].originalName;
38286
38225
  const alias = viewName === origViewName ? void 0 : joinMeta.alias;
38287
38226
  joinsArray.push(
38288
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
38227
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
38289
38228
  );
38290
38229
  } else {
38291
38230
  joinsArray.push(
38292
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22} on ${joinMeta.on}`
38231
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}${onSql}`
38293
38232
  );
38294
38233
  }
38295
38234
  if (index6 < joins.length - 1) {
@@ -38312,7 +38251,7 @@ var init_dialect3 = __esm({
38312
38251
  const { config, strength } = lockingClause;
38313
38252
  lockingClausesSql = sql` for ${sql.raw(strength)}`;
38314
38253
  if (config.noWait) {
38315
- lockingClausesSql.append(sql` no wait`);
38254
+ lockingClausesSql.append(sql` nowait`);
38316
38255
  } else if (config.skipLocked) {
38317
38256
  lockingClausesSql.append(sql` skip locked`);
38318
38257
  }
@@ -39179,17 +39118,18 @@ var init_select4 = __esm({
39179
39118
  *
39180
39119
  * @param table the table to join.
39181
39120
  * @param on the `on` clause.
39121
+ * @param onIndex index hint.
39182
39122
  *
39183
39123
  * @example
39184
39124
  *
39185
39125
  * ```ts
39186
39126
  * // Select all users and their pets
39187
- * const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
39127
+ * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
39188
39128
  * .from(users)
39189
39129
  * .leftJoin(pets, eq(users.id, pets.ownerId))
39190
39130
  *
39191
39131
  * // Select userId and petId
39192
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
39132
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
39193
39133
  * userId: users.id,
39194
39134
  * petId: pets.id,
39195
39135
  * })
@@ -39197,7 +39137,7 @@ var init_select4 = __esm({
39197
39137
  * .leftJoin(pets, eq(users.id, pets.ownerId))
39198
39138
  *
39199
39139
  * // Select userId and petId with use index hint
39200
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
39140
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
39201
39141
  * userId: users.id,
39202
39142
  * petId: pets.id,
39203
39143
  * })
@@ -39207,7 +39147,20 @@ var init_select4 = __esm({
39207
39147
  * })
39208
39148
  * ```
39209
39149
  */
39210
- __publicField(this, "leftJoin", this.createJoin("left"));
39150
+ __publicField(this, "leftJoin", this.createJoin("left", false));
39151
+ /**
39152
+ * Executes a `left join lateral` operation by adding subquery to the current query.
39153
+ *
39154
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
39155
+ *
39156
+ * Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.
39157
+ *
39158
+ * See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
39159
+ *
39160
+ * @param table the subquery to join.
39161
+ * @param on the `on` clause.
39162
+ */
39163
+ __publicField(this, "leftJoinLateral", this.createJoin("left", true));
39211
39164
  /**
39212
39165
  * Executes a `right join` operation by adding another table to the current query.
39213
39166
  *
@@ -39217,17 +39170,18 @@ var init_select4 = __esm({
39217
39170
  *
39218
39171
  * @param table the table to join.
39219
39172
  * @param on the `on` clause.
39173
+ * @param onIndex index hint.
39220
39174
  *
39221
39175
  * @example
39222
39176
  *
39223
39177
  * ```ts
39224
39178
  * // Select all users and their pets
39225
- * const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
39179
+ * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
39226
39180
  * .from(users)
39227
39181
  * .rightJoin(pets, eq(users.id, pets.ownerId))
39228
39182
  *
39229
39183
  * // Select userId and petId
39230
- * const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
39184
+ * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
39231
39185
  * userId: users.id,
39232
39186
  * petId: pets.id,
39233
39187
  * })
@@ -39235,7 +39189,7 @@ var init_select4 = __esm({
39235
39189
  * .rightJoin(pets, eq(users.id, pets.ownerId))
39236
39190
  *
39237
39191
  * // Select userId and petId with use index hint
39238
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
39192
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
39239
39193
  * userId: users.id,
39240
39194
  * petId: pets.id,
39241
39195
  * })
@@ -39245,7 +39199,7 @@ var init_select4 = __esm({
39245
39199
  * })
39246
39200
  * ```
39247
39201
  */
39248
- __publicField(this, "rightJoin", this.createJoin("right"));
39202
+ __publicField(this, "rightJoin", this.createJoin("right", false));
39249
39203
  /**
39250
39204
  * Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
39251
39205
  *
@@ -39255,17 +39209,18 @@ var init_select4 = __esm({
39255
39209
  *
39256
39210
  * @param table the table to join.
39257
39211
  * @param on the `on` clause.
39212
+ * @param onIndex index hint.
39258
39213
  *
39259
39214
  * @example
39260
39215
  *
39261
39216
  * ```ts
39262
39217
  * // Select all users and their pets
39263
- * const usersWithPets: { user: User; pets: Pet }[] = await db.select()
39218
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
39264
39219
  * .from(users)
39265
39220
  * .innerJoin(pets, eq(users.id, pets.ownerId))
39266
39221
  *
39267
39222
  * // Select userId and petId
39268
- * const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
39223
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
39269
39224
  * userId: users.id,
39270
39225
  * petId: pets.id,
39271
39226
  * })
@@ -39273,7 +39228,7 @@ var init_select4 = __esm({
39273
39228
  * .innerJoin(pets, eq(users.id, pets.ownerId))
39274
39229
  *
39275
39230
  * // Select userId and petId with use index hint
39276
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
39231
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
39277
39232
  * userId: users.id,
39278
39233
  * petId: pets.id,
39279
39234
  * })
@@ -39283,45 +39238,70 @@ var init_select4 = __esm({
39283
39238
  * })
39284
39239
  * ```
39285
39240
  */
39286
- __publicField(this, "innerJoin", this.createJoin("inner"));
39241
+ __publicField(this, "innerJoin", this.createJoin("inner", false));
39287
39242
  /**
39288
- * Executes a `full join` operation by combining rows from two tables into a new table.
39243
+ * Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
39289
39244
  *
39290
- * Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in `null` for non-matching columns.
39245
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
39291
39246
  *
39292
- * See docs: {@link https://orm.drizzle.team/docs/joins#full-join}
39247
+ * Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.
39293
39248
  *
39294
- * @param table the table to join.
39249
+ * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
39250
+ *
39251
+ * @param table the subquery to join.
39295
39252
  * @param on the `on` clause.
39253
+ */
39254
+ __publicField(this, "innerJoinLateral", this.createJoin("inner", true));
39255
+ /**
39256
+ * Executes a `cross join` operation by combining rows from two tables into a new table.
39257
+ *
39258
+ * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
39259
+ *
39260
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
39261
+ *
39262
+ * @param table the table to join.
39263
+ * @param onIndex index hint.
39296
39264
  *
39297
39265
  * @example
39298
39266
  *
39299
39267
  * ```ts
39300
- * // Select all users and their pets
39301
- * const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
39268
+ * // Select all users, each user with every pet
39269
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
39302
39270
  * .from(users)
39303
- * .fullJoin(pets, eq(users.id, pets.ownerId))
39271
+ * .crossJoin(pets)
39304
39272
  *
39305
39273
  * // Select userId and petId
39306
- * const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
39274
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
39307
39275
  * userId: users.id,
39308
39276
  * petId: pets.id,
39309
39277
  * })
39310
39278
  * .from(users)
39311
- * .fullJoin(pets, eq(users.id, pets.ownerId))
39279
+ * .crossJoin(pets)
39312
39280
  *
39313
39281
  * // Select userId and petId with use index hint
39314
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
39282
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
39315
39283
  * userId: users.id,
39316
39284
  * petId: pets.id,
39317
39285
  * })
39318
39286
  * .from(users)
39319
- * .leftJoin(pets, eq(users.id, pets.ownerId), {
39287
+ * .crossJoin(pets, {
39320
39288
  * useIndex: ['pets_owner_id_index']
39321
39289
  * })
39322
39290
  * ```
39323
39291
  */
39324
- __publicField(this, "fullJoin", this.createJoin("full"));
39292
+ __publicField(this, "crossJoin", this.createJoin("cross", false));
39293
+ /**
39294
+ * Executes a `cross join lateral` operation by combining rows from two queries into a new table.
39295
+ *
39296
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
39297
+ *
39298
+ * Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
39299
+ *
39300
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
39301
+ *
39302
+ * @param table the query to join.
39303
+ */
39304
+ __publicField(this, "crossJoinLateral", this.createJoin("cross", true));
39325
39305
  /**
39326
39306
  * Adds `union` set operator to the query.
39327
39307
  *
@@ -39527,8 +39507,11 @@ var init_select4 = __esm({
39527
39507
  this.tableName = getTableLikeName(table6);
39528
39508
  this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
39529
39509
  }
39530
- createJoin(joinType) {
39531
- return (table6, on, onIndex) => {
39510
+ createJoin(joinType, lateral) {
39511
+ return (table6, a, b) => {
39512
+ const isCrossJoin = joinType === "cross";
39513
+ let on = isCrossJoin ? void 0 : a;
39514
+ const onIndex = isCrossJoin ? a : b;
39532
39515
  const baseTableName = this.tableName;
39533
39516
  const tableName = getTableLikeName(table6);
39534
39517
  if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
@@ -39570,7 +39553,7 @@ var init_select4 = __esm({
39570
39553
  ignoreIndex = convertIndexToString(toArray(onIndex.ignoreIndex));
39571
39554
  }
39572
39555
  }
39573
- this.config.joins.push({ on, table: table6, joinType, alias: tableName, useIndex, forceIndex, ignoreIndex });
39556
+ this.config.joins.push({ on, table: table6, joinType, alias: tableName, useIndex, forceIndex, ignoreIndex, lateral });
39574
39557
  if (typeof tableName === "string") {
39575
39558
  switch (joinType) {
39576
39559
  case "left": {
@@ -39584,17 +39567,11 @@ var init_select4 = __esm({
39584
39567
  this.joinsNotNullableMap[tableName] = true;
39585
39568
  break;
39586
39569
  }
39570
+ case "cross":
39587
39571
  case "inner": {
39588
39572
  this.joinsNotNullableMap[tableName] = true;
39589
39573
  break;
39590
39574
  }
39591
- case "full": {
39592
- this.joinsNotNullableMap = Object.fromEntries(
39593
- Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
39594
- );
39595
- this.joinsNotNullableMap[tableName] = false;
39596
- break;
39597
- }
39598
39575
  }
39599
39576
  }
39600
39577
  return this;
@@ -42232,10 +42209,8 @@ var init_binary2 = __esm({
42232
42209
  __publicField(this, "length", this.config.length);
42233
42210
  }
42234
42211
  mapFromDriverValue(value) {
42235
- if (typeof value === "string")
42236
- return value;
42237
- if (Buffer.isBuffer(value))
42238
- return value.toString();
42212
+ if (typeof value === "string") return value;
42213
+ if (Buffer.isBuffer(value)) return value.toString();
42239
42214
  const str = [];
42240
42215
  for (const v of value) {
42241
42216
  str.push(v === 49 ? "1" : "0");
@@ -42562,8 +42537,7 @@ var init_decimal2 = __esm({
42562
42537
  __publicField(this, "unsigned", this.config.unsigned);
42563
42538
  }
42564
42539
  mapFromDriverValue(value) {
42565
- if (typeof value === "string")
42566
- return value;
42540
+ if (typeof value === "string") return value;
42567
42541
  return String(value);
42568
42542
  }
42569
42543
  getSQLType() {
@@ -42605,8 +42579,7 @@ var init_decimal2 = __esm({
42605
42579
  __publicField(this, "mapToDriverValue", String);
42606
42580
  }
42607
42581
  mapFromDriverValue(value) {
42608
- if (typeof value === "number")
42609
- return value;
42582
+ if (typeof value === "number") return value;
42610
42583
  return Number(value);
42611
42584
  }
42612
42585
  getSQLType() {
@@ -43315,10 +43288,8 @@ var init_varbinary2 = __esm({
43315
43288
  __publicField(this, "length", this.config.length);
43316
43289
  }
43317
43290
  mapFromDriverValue(value) {
43318
- if (typeof value === "string")
43319
- return value;
43320
- if (Buffer.isBuffer(value))
43321
- return value.toString();
43291
+ if (typeof value === "string") return value;
43292
+ if (Buffer.isBuffer(value)) return value.toString();
43322
43293
  const str = [];
43323
43294
  for (const v of value) {
43324
43295
  str.push(v === 49 ? "1" : "0");
@@ -43942,8 +43913,7 @@ var init_dialect4 = __esm({
43942
43913
  return `'${str.replace(/'/g, "''")}'`;
43943
43914
  }
43944
43915
  buildWithCTE(queries) {
43945
- if (!queries?.length)
43946
- return void 0;
43916
+ if (!queries?.length) return void 0;
43947
43917
  const withSqlChunks = [sql`with `];
43948
43918
  for (const [i, w] of queries.entries()) {
43949
43919
  withSqlChunks.push(sql`${sql.identifier(w._.alias)} as (${w._.sql})`);
@@ -44088,13 +44058,14 @@ var init_dialect4 = __esm({
44088
44058
  }
44089
44059
  const table22 = joinMeta.table;
44090
44060
  const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
44061
+ const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
44091
44062
  if (is(table22, SingleStoreTable)) {
44092
44063
  const tableName = table22[SingleStoreTable.Symbol.Name];
44093
44064
  const tableSchema = table22[SingleStoreTable.Symbol.Schema];
44094
44065
  const origTableName = table22[SingleStoreTable.Symbol.OriginalName];
44095
44066
  const alias = tableName === origTableName ? void 0 : joinMeta.alias;
44096
44067
  joinsArray.push(
44097
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
44068
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
44098
44069
  );
44099
44070
  } else if (is(table22, View3)) {
44100
44071
  const viewName = table22[ViewBaseConfig].name;
@@ -44102,11 +44073,11 @@ var init_dialect4 = __esm({
44102
44073
  const origViewName = table22[ViewBaseConfig].originalName;
44103
44074
  const alias = viewName === origViewName ? void 0 : joinMeta.alias;
44104
44075
  joinsArray.push(
44105
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
44076
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
44106
44077
  );
44107
44078
  } else {
44108
44079
  joinsArray.push(
44109
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22} on ${joinMeta.on}`
44080
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}${onSql}`
44110
44081
  );
44111
44082
  }
44112
44083
  if (index6 < joins.length - 1) {
@@ -44126,7 +44097,7 @@ var init_dialect4 = __esm({
44126
44097
  const { config, strength } = lockingClause;
44127
44098
  lockingClausesSql = sql` for ${sql.raw(strength)}`;
44128
44099
  if (config.noWait) {
44129
- lockingClausesSql.append(sql` no wait`);
44100
+ lockingClausesSql.append(sql` nowait`);
44130
44101
  } else if (config.skipLocked) {
44131
44102
  lockingClausesSql.append(sql` skip locked`);
44132
44103
  }
@@ -44566,12 +44537,12 @@ var init_select5 = __esm({
44566
44537
  *
44567
44538
  * ```ts
44568
44539
  * // Select all users and their pets
44569
- * const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
44540
+ * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
44570
44541
  * .from(users)
44571
44542
  * .leftJoin(pets, eq(users.id, pets.ownerId))
44572
44543
  *
44573
44544
  * // Select userId and petId
44574
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
44545
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
44575
44546
  * userId: users.id,
44576
44547
  * petId: pets.id,
44577
44548
  * })
@@ -44579,7 +44550,20 @@ var init_select5 = __esm({
44579
44550
  * .leftJoin(pets, eq(users.id, pets.ownerId))
44580
44551
  * ```
44581
44552
  */
44582
- __publicField(this, "leftJoin", this.createJoin("left"));
44553
+ __publicField(this, "leftJoin", this.createJoin("left", false));
44554
+ /**
44555
+ * Executes a `left join lateral` operation by adding subquery to the current query.
44556
+ *
44557
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
44558
+ *
44559
+ * Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.
44560
+ *
44561
+ * See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
44562
+ *
44563
+ * @param table the subquery to join.
44564
+ * @param on the `on` clause.
44565
+ */
44566
+ __publicField(this, "leftJoinLateral", this.createJoin("left", true));
44583
44567
  /**
44584
44568
  * Executes a `right join` operation by adding another table to the current query.
44585
44569
  *
@@ -44594,12 +44578,12 @@ var init_select5 = __esm({
44594
44578
  *
44595
44579
  * ```ts
44596
44580
  * // Select all users and their pets
44597
- * const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
44581
+ * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
44598
44582
  * .from(users)
44599
44583
  * .rightJoin(pets, eq(users.id, pets.ownerId))
44600
44584
  *
44601
44585
  * // Select userId and petId
44602
- * const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
44586
+ * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
44603
44587
  * userId: users.id,
44604
44588
  * petId: pets.id,
44605
44589
  * })
@@ -44607,7 +44591,7 @@ var init_select5 = __esm({
44607
44591
  * .rightJoin(pets, eq(users.id, pets.ownerId))
44608
44592
  * ```
44609
44593
  */
44610
- __publicField(this, "rightJoin", this.createJoin("right"));
44594
+ __publicField(this, "rightJoin", this.createJoin("right", false));
44611
44595
  /**
44612
44596
  * Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
44613
44597
  *
@@ -44622,12 +44606,12 @@ var init_select5 = __esm({
44622
44606
  *
44623
44607
  * ```ts
44624
44608
  * // Select all users and their pets
44625
- * const usersWithPets: { user: User; pets: Pet }[] = await db.select()
44609
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
44626
44610
  * .from(users)
44627
44611
  * .innerJoin(pets, eq(users.id, pets.ownerId))
44628
44612
  *
44629
44613
  * // Select userId and petId
44630
- * const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
44614
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
44631
44615
  * userId: users.id,
44632
44616
  * petId: pets.id,
44633
44617
  * })
@@ -44635,7 +44619,20 @@ var init_select5 = __esm({
44635
44619
  * .innerJoin(pets, eq(users.id, pets.ownerId))
44636
44620
  * ```
44637
44621
  */
44638
- __publicField(this, "innerJoin", this.createJoin("inner"));
44622
+ __publicField(this, "innerJoin", this.createJoin("inner", false));
44623
+ /**
44624
+ * Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
44625
+ *
44626
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
44627
+ *
44628
+ * Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.
44629
+ *
44630
+ * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
44631
+ *
44632
+ * @param table the subquery to join.
44633
+ * @param on the `on` clause.
44634
+ */
44635
+ __publicField(this, "innerJoinLateral", this.createJoin("inner", true));
44639
44636
  /**
44640
44637
  * Executes a `full join` operation by combining rows from two tables into a new table.
44641
44638
  *
@@ -44650,12 +44647,12 @@ var init_select5 = __esm({
44650
44647
  *
44651
44648
  * ```ts
44652
44649
  * // Select all users and their pets
44653
- * const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
44650
+ * const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
44654
44651
  * .from(users)
44655
44652
  * .fullJoin(pets, eq(users.id, pets.ownerId))
44656
44653
  *
44657
44654
  * // Select userId and petId
44658
- * const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
44655
+ * const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
44659
44656
  * userId: users.id,
44660
44657
  * petId: pets.id,
44661
44658
  * })
@@ -44663,7 +44660,46 @@ var init_select5 = __esm({
44663
44660
  * .fullJoin(pets, eq(users.id, pets.ownerId))
44664
44661
  * ```
44665
44662
  */
44666
- __publicField(this, "fullJoin", this.createJoin("full"));
44663
+ __publicField(this, "fullJoin", this.createJoin("full", false));
44664
+ /**
44665
+ * Executes a `cross join` operation by combining rows from two tables into a new table.
44666
+ *
44667
+ * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
44668
+ *
44669
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
44670
+ *
44671
+ * @param table the table to join.
44672
+ *
44673
+ * @example
44674
+ *
44675
+ * ```ts
44676
+ * // Select all users, each user with every pet
44677
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
44678
+ * .from(users)
44679
+ * .crossJoin(pets)
44680
+ *
44681
+ * // Select userId and petId
44682
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
44683
+ * userId: users.id,
44684
+ * petId: pets.id,
44685
+ * })
44686
+ * .from(users)
44687
+ * .crossJoin(pets)
44688
+ * ```
44689
+ */
44690
+ __publicField(this, "crossJoin", this.createJoin("cross", false));
44691
+ /**
44692
+ * Executes a `cross join lateral` operation by combining rows from two queries into a new table.
44693
+ *
44694
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
44695
+ *
44696
+ * Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
44697
+ *
44698
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
44699
+ *
44700
+ * @param table the query to join.
44701
+ */
44702
+ __publicField(this, "crossJoinLateral", this.createJoin("cross", true));
44667
44703
  /**
44668
44704
  * Adds `union` set operator to the query.
44669
44705
  *
@@ -44808,7 +44844,7 @@ var init_select5 = __esm({
44808
44844
  this.tableName = getTableLikeName(table6);
44809
44845
  this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
44810
44846
  }
44811
- createJoin(joinType) {
44847
+ createJoin(joinType, lateral) {
44812
44848
  return (table6, on) => {
44813
44849
  const baseTableName = this.tableName;
44814
44850
  const tableName = getTableLikeName(table6);
@@ -44837,7 +44873,7 @@ var init_select5 = __esm({
44837
44873
  if (!this.config.joins) {
44838
44874
  this.config.joins = [];
44839
44875
  }
44840
- this.config.joins.push({ on, table: table6, joinType, alias: tableName });
44876
+ this.config.joins.push({ on, table: table6, joinType, alias: tableName, lateral });
44841
44877
  if (typeof tableName === "string") {
44842
44878
  switch (joinType) {
44843
44879
  case "left": {
@@ -44851,6 +44887,7 @@ var init_select5 = __esm({
44851
44887
  this.joinsNotNullableMap[tableName] = true;
44852
44888
  break;
44853
44889
  }
44890
+ case "cross":
44854
44891
  case "inner": {
44855
44892
  this.joinsNotNullableMap[tableName] = true;
44856
44893
  break;