drizzle-kit 1.0.0-beta.1-00df263 → 1.0.0-beta.1-19a7308

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 (4) hide show
  1. package/api.js +286 -84
  2. package/api.mjs +286 -84
  3. package/bin.cjs +1 -1
  4. package/package.json +1 -1
package/api.js CHANGED
@@ -27245,13 +27245,14 @@ var init_dialect = __esm({
27245
27245
  }
27246
27246
  const table6 = joinMeta.table;
27247
27247
  const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
27248
+ const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
27248
27249
  if (is(table6, PgTable)) {
27249
27250
  const tableName = table6[PgTable.Symbol.Name];
27250
27251
  const tableSchema = table6[PgTable.Symbol.Schema];
27251
27252
  const origTableName = table6[PgTable.Symbol.OriginalName];
27252
27253
  const alias = tableName === origTableName ? void 0 : joinMeta.alias;
27253
27254
  joinsArray.push(
27254
- 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}`
27255
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
27255
27256
  );
27256
27257
  } else if (is(table6, View3)) {
27257
27258
  const viewName = table6[ViewBaseConfig].name;
@@ -27259,11 +27260,11 @@ var init_dialect = __esm({
27259
27260
  const origViewName = table6[ViewBaseConfig].originalName;
27260
27261
  const alias = viewName === origViewName ? void 0 : joinMeta.alias;
27261
27262
  joinsArray.push(
27262
- 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}`
27263
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
27263
27264
  );
27264
27265
  } else {
27265
27266
  joinsArray.push(
27266
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table6} on ${joinMeta.on}`
27267
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table6}${onSql}`
27267
27268
  );
27268
27269
  }
27269
27270
  if (index6 < joins.length - 1) {
@@ -27342,7 +27343,7 @@ var init_dialect = __esm({
27342
27343
  );
27343
27344
  }
27344
27345
  if (lockingClause.config.noWait) {
27345
- clauseSql.append(sql` no wait`);
27346
+ clauseSql.append(sql` nowait`);
27346
27347
  } else if (lockingClause.config.skipLocked) {
27347
27348
  clauseSql.append(sql` skip locked`);
27348
27349
  }
@@ -27971,12 +27972,12 @@ var init_select2 = __esm({
27971
27972
  *
27972
27973
  * ```ts
27973
27974
  * // Select all users and their pets
27974
- * const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
27975
+ * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
27975
27976
  * .from(users)
27976
27977
  * .leftJoin(pets, eq(users.id, pets.ownerId))
27977
27978
  *
27978
27979
  * // Select userId and petId
27979
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
27980
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
27980
27981
  * userId: users.id,
27981
27982
  * petId: pets.id,
27982
27983
  * })
@@ -27984,7 +27985,20 @@ var init_select2 = __esm({
27984
27985
  * .leftJoin(pets, eq(users.id, pets.ownerId))
27985
27986
  * ```
27986
27987
  */
27987
- __publicField(this, "leftJoin", this.createJoin("left"));
27988
+ __publicField(this, "leftJoin", this.createJoin("left", false));
27989
+ /**
27990
+ * Executes a `left join lateral` operation by adding subquery to the current query.
27991
+ *
27992
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
27993
+ *
27994
+ * 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.
27995
+ *
27996
+ * See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
27997
+ *
27998
+ * @param table the subquery to join.
27999
+ * @param on the `on` clause.
28000
+ */
28001
+ __publicField(this, "leftJoinLateral", this.createJoin("left", true));
27988
28002
  /**
27989
28003
  * Executes a `right join` operation by adding another table to the current query.
27990
28004
  *
@@ -27999,12 +28013,12 @@ var init_select2 = __esm({
27999
28013
  *
28000
28014
  * ```ts
28001
28015
  * // Select all users and their pets
28002
- * const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
28016
+ * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
28003
28017
  * .from(users)
28004
28018
  * .rightJoin(pets, eq(users.id, pets.ownerId))
28005
28019
  *
28006
28020
  * // Select userId and petId
28007
- * const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
28021
+ * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
28008
28022
  * userId: users.id,
28009
28023
  * petId: pets.id,
28010
28024
  * })
@@ -28012,7 +28026,7 @@ var init_select2 = __esm({
28012
28026
  * .rightJoin(pets, eq(users.id, pets.ownerId))
28013
28027
  * ```
28014
28028
  */
28015
- __publicField(this, "rightJoin", this.createJoin("right"));
28029
+ __publicField(this, "rightJoin", this.createJoin("right", false));
28016
28030
  /**
28017
28031
  * Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
28018
28032
  *
@@ -28027,12 +28041,12 @@ var init_select2 = __esm({
28027
28041
  *
28028
28042
  * ```ts
28029
28043
  * // Select all users and their pets
28030
- * const usersWithPets: { user: User; pets: Pet }[] = await db.select()
28044
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
28031
28045
  * .from(users)
28032
28046
  * .innerJoin(pets, eq(users.id, pets.ownerId))
28033
28047
  *
28034
28048
  * // Select userId and petId
28035
- * const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
28049
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
28036
28050
  * userId: users.id,
28037
28051
  * petId: pets.id,
28038
28052
  * })
@@ -28040,7 +28054,20 @@ var init_select2 = __esm({
28040
28054
  * .innerJoin(pets, eq(users.id, pets.ownerId))
28041
28055
  * ```
28042
28056
  */
28043
- __publicField(this, "innerJoin", this.createJoin("inner"));
28057
+ __publicField(this, "innerJoin", this.createJoin("inner", false));
28058
+ /**
28059
+ * Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
28060
+ *
28061
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
28062
+ *
28063
+ * 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.
28064
+ *
28065
+ * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
28066
+ *
28067
+ * @param table the subquery to join.
28068
+ * @param on the `on` clause.
28069
+ */
28070
+ __publicField(this, "innerJoinLateral", this.createJoin("inner", true));
28044
28071
  /**
28045
28072
  * Executes a `full join` operation by combining rows from two tables into a new table.
28046
28073
  *
@@ -28055,12 +28082,12 @@ var init_select2 = __esm({
28055
28082
  *
28056
28083
  * ```ts
28057
28084
  * // Select all users and their pets
28058
- * const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
28085
+ * const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
28059
28086
  * .from(users)
28060
28087
  * .fullJoin(pets, eq(users.id, pets.ownerId))
28061
28088
  *
28062
28089
  * // Select userId and petId
28063
- * const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
28090
+ * const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
28064
28091
  * userId: users.id,
28065
28092
  * petId: pets.id,
28066
28093
  * })
@@ -28068,7 +28095,46 @@ var init_select2 = __esm({
28068
28095
  * .fullJoin(pets, eq(users.id, pets.ownerId))
28069
28096
  * ```
28070
28097
  */
28071
- __publicField(this, "fullJoin", this.createJoin("full"));
28098
+ __publicField(this, "fullJoin", this.createJoin("full", false));
28099
+ /**
28100
+ * Executes a `cross join` operation by combining rows from two tables into a new table.
28101
+ *
28102
+ * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
28103
+ *
28104
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
28105
+ *
28106
+ * @param table the table to join.
28107
+ *
28108
+ * @example
28109
+ *
28110
+ * ```ts
28111
+ * // Select all users, each user with every pet
28112
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
28113
+ * .from(users)
28114
+ * .crossJoin(pets)
28115
+ *
28116
+ * // Select userId and petId
28117
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
28118
+ * userId: users.id,
28119
+ * petId: pets.id,
28120
+ * })
28121
+ * .from(users)
28122
+ * .crossJoin(pets)
28123
+ * ```
28124
+ */
28125
+ __publicField(this, "crossJoin", this.createJoin("cross", false));
28126
+ /**
28127
+ * Executes a `cross join lateral` operation by combining rows from two queries into a new table.
28128
+ *
28129
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
28130
+ *
28131
+ * Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
28132
+ *
28133
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
28134
+ *
28135
+ * @param table the query to join.
28136
+ */
28137
+ __publicField(this, "crossJoinLateral", this.createJoin("cross", true));
28072
28138
  /**
28073
28139
  * Adds `union` set operator to the query.
28074
28140
  *
@@ -28271,7 +28337,7 @@ var init_select2 = __esm({
28271
28337
  this.tableName = getTableLikeName(table6);
28272
28338
  this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
28273
28339
  }
28274
- createJoin(joinType) {
28340
+ createJoin(joinType, lateral) {
28275
28341
  return (table6, on) => {
28276
28342
  const baseTableName = this.tableName;
28277
28343
  const tableName = getTableLikeName(table6);
@@ -28300,7 +28366,7 @@ var init_select2 = __esm({
28300
28366
  if (!this.config.joins) {
28301
28367
  this.config.joins = [];
28302
28368
  }
28303
- this.config.joins.push({ on, table: table6, joinType, alias: tableName });
28369
+ this.config.joins.push({ on, table: table6, joinType, alias: tableName, lateral });
28304
28370
  if (typeof tableName === "string") {
28305
28371
  switch (joinType) {
28306
28372
  case "left": {
@@ -28314,6 +28380,7 @@ var init_select2 = __esm({
28314
28380
  this.joinsNotNullableMap[tableName] = true;
28315
28381
  break;
28316
28382
  }
28383
+ case "cross":
28317
28384
  case "inner": {
28318
28385
  this.joinsNotNullableMap[tableName] = true;
28319
28386
  break;
@@ -33494,17 +33561,18 @@ var init_dialect2 = __esm({
33494
33561
  joinsArray.push(sql` `);
33495
33562
  }
33496
33563
  const table6 = joinMeta.table;
33564
+ const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
33497
33565
  if (is(table6, SQLiteTable)) {
33498
33566
  const tableName = table6[SQLiteTable.Symbol.Name];
33499
33567
  const tableSchema = table6[SQLiteTable.Symbol.Schema];
33500
33568
  const origTableName = table6[SQLiteTable.Symbol.OriginalName];
33501
33569
  const alias = tableName === origTableName ? void 0 : joinMeta.alias;
33502
33570
  joinsArray.push(
33503
- sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
33571
+ sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
33504
33572
  );
33505
33573
  } else {
33506
33574
  joinsArray.push(
33507
- sql`${sql.raw(joinMeta.joinType)} join ${table6} on ${joinMeta.on}`
33575
+ sql`${sql.raw(joinMeta.joinType)} join ${table6}${onSql}`
33508
33576
  );
33509
33577
  }
33510
33578
  if (index6 < joins.length - 1) {
@@ -34210,12 +34278,12 @@ var init_select3 = __esm({
34210
34278
  *
34211
34279
  * ```ts
34212
34280
  * // Select all users and their pets
34213
- * const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
34281
+ * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
34214
34282
  * .from(users)
34215
34283
  * .leftJoin(pets, eq(users.id, pets.ownerId))
34216
34284
  *
34217
34285
  * // Select userId and petId
34218
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
34286
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
34219
34287
  * userId: users.id,
34220
34288
  * petId: pets.id,
34221
34289
  * })
@@ -34238,12 +34306,12 @@ var init_select3 = __esm({
34238
34306
  *
34239
34307
  * ```ts
34240
34308
  * // Select all users and their pets
34241
- * const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
34309
+ * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
34242
34310
  * .from(users)
34243
34311
  * .rightJoin(pets, eq(users.id, pets.ownerId))
34244
34312
  *
34245
34313
  * // Select userId and petId
34246
- * const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
34314
+ * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
34247
34315
  * userId: users.id,
34248
34316
  * petId: pets.id,
34249
34317
  * })
@@ -34266,12 +34334,12 @@ var init_select3 = __esm({
34266
34334
  *
34267
34335
  * ```ts
34268
34336
  * // Select all users and their pets
34269
- * const usersWithPets: { user: User; pets: Pet }[] = await db.select()
34337
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
34270
34338
  * .from(users)
34271
34339
  * .innerJoin(pets, eq(users.id, pets.ownerId))
34272
34340
  *
34273
34341
  * // Select userId and petId
34274
- * const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
34342
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
34275
34343
  * userId: users.id,
34276
34344
  * petId: pets.id,
34277
34345
  * })
@@ -34294,12 +34362,12 @@ var init_select3 = __esm({
34294
34362
  *
34295
34363
  * ```ts
34296
34364
  * // Select all users and their pets
34297
- * const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
34365
+ * const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
34298
34366
  * .from(users)
34299
34367
  * .fullJoin(pets, eq(users.id, pets.ownerId))
34300
34368
  *
34301
34369
  * // Select userId and petId
34302
- * const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
34370
+ * const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
34303
34371
  * userId: users.id,
34304
34372
  * petId: pets.id,
34305
34373
  * })
@@ -34308,6 +34376,33 @@ var init_select3 = __esm({
34308
34376
  * ```
34309
34377
  */
34310
34378
  __publicField(this, "fullJoin", this.createJoin("full"));
34379
+ /**
34380
+ * Executes a `cross join` operation by combining rows from two tables into a new table.
34381
+ *
34382
+ * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
34383
+ *
34384
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
34385
+ *
34386
+ * @param table the table to join.
34387
+ *
34388
+ * @example
34389
+ *
34390
+ * ```ts
34391
+ * // Select all users, each user with every pet
34392
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
34393
+ * .from(users)
34394
+ * .crossJoin(pets)
34395
+ *
34396
+ * // Select userId and petId
34397
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
34398
+ * userId: users.id,
34399
+ * petId: pets.id,
34400
+ * })
34401
+ * .from(users)
34402
+ * .crossJoin(pets)
34403
+ * ```
34404
+ */
34405
+ __publicField(this, "crossJoin", this.createJoin("cross"));
34311
34406
  /**
34312
34407
  * Adds `union` set operator to the query.
34313
34408
  *
@@ -34471,6 +34566,7 @@ var init_select3 = __esm({
34471
34566
  this.joinsNotNullableMap[tableName] = true;
34472
34567
  break;
34473
34568
  }
34569
+ case "cross":
34474
34570
  case "inner": {
34475
34571
  this.joinsNotNullableMap[tableName] = true;
34476
34572
  break;
@@ -39336,6 +39432,7 @@ var init_dialect3 = __esm({
39336
39432
  }
39337
39433
  const table22 = joinMeta.table;
39338
39434
  const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
39435
+ const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
39339
39436
  if (is(table22, MySqlTable)) {
39340
39437
  const tableName = table22[MySqlTable.Symbol.Name];
39341
39438
  const tableSchema = table22[MySqlTable.Symbol.Schema];
@@ -39345,7 +39442,7 @@ var init_dialect3 = __esm({
39345
39442
  const forceIndexSql2 = this.buildIndex({ indexes: joinMeta.forceIndex, indexFor: "FORCE" });
39346
39443
  const ignoreIndexSql2 = this.buildIndex({ indexes: joinMeta.ignoreIndex, indexFor: "IGNORE" });
39347
39444
  joinsArray.push(
39348
- 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}`
39445
+ 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}`
39349
39446
  );
39350
39447
  } else if (is(table22, View3)) {
39351
39448
  const viewName = table22[ViewBaseConfig].name;
@@ -39353,11 +39450,11 @@ var init_dialect3 = __esm({
39353
39450
  const origViewName = table22[ViewBaseConfig].originalName;
39354
39451
  const alias = viewName === origViewName ? void 0 : joinMeta.alias;
39355
39452
  joinsArray.push(
39356
- 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}`
39453
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
39357
39454
  );
39358
39455
  } else {
39359
39456
  joinsArray.push(
39360
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22} on ${joinMeta.on}`
39457
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}${onSql}`
39361
39458
  );
39362
39459
  }
39363
39460
  if (index6 < joins.length - 1) {
@@ -39380,7 +39477,7 @@ var init_dialect3 = __esm({
39380
39477
  const { config, strength } = lockingClause;
39381
39478
  lockingClausesSql = sql` for ${sql.raw(strength)}`;
39382
39479
  if (config.noWait) {
39383
- lockingClausesSql.append(sql` no wait`);
39480
+ lockingClausesSql.append(sql` nowait`);
39384
39481
  } else if (config.skipLocked) {
39385
39482
  lockingClausesSql.append(sql` skip locked`);
39386
39483
  }
@@ -40382,17 +40479,18 @@ var init_select4 = __esm({
40382
40479
  *
40383
40480
  * @param table the table to join.
40384
40481
  * @param on the `on` clause.
40482
+ * @param onIndex index hint.
40385
40483
  *
40386
40484
  * @example
40387
40485
  *
40388
40486
  * ```ts
40389
40487
  * // Select all users and their pets
40390
- * const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
40488
+ * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
40391
40489
  * .from(users)
40392
40490
  * .leftJoin(pets, eq(users.id, pets.ownerId))
40393
40491
  *
40394
40492
  * // Select userId and petId
40395
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
40493
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
40396
40494
  * userId: users.id,
40397
40495
  * petId: pets.id,
40398
40496
  * })
@@ -40400,7 +40498,7 @@ var init_select4 = __esm({
40400
40498
  * .leftJoin(pets, eq(users.id, pets.ownerId))
40401
40499
  *
40402
40500
  * // Select userId and petId with use index hint
40403
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
40501
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
40404
40502
  * userId: users.id,
40405
40503
  * petId: pets.id,
40406
40504
  * })
@@ -40410,7 +40508,20 @@ var init_select4 = __esm({
40410
40508
  * })
40411
40509
  * ```
40412
40510
  */
40413
- __publicField(this, "leftJoin", this.createJoin("left"));
40511
+ __publicField(this, "leftJoin", this.createJoin("left", false));
40512
+ /**
40513
+ * Executes a `left join lateral` operation by adding subquery to the current query.
40514
+ *
40515
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
40516
+ *
40517
+ * 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.
40518
+ *
40519
+ * See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
40520
+ *
40521
+ * @param table the subquery to join.
40522
+ * @param on the `on` clause.
40523
+ */
40524
+ __publicField(this, "leftJoinLateral", this.createJoin("left", true));
40414
40525
  /**
40415
40526
  * Executes a `right join` operation by adding another table to the current query.
40416
40527
  *
@@ -40420,17 +40531,18 @@ var init_select4 = __esm({
40420
40531
  *
40421
40532
  * @param table the table to join.
40422
40533
  * @param on the `on` clause.
40534
+ * @param onIndex index hint.
40423
40535
  *
40424
40536
  * @example
40425
40537
  *
40426
40538
  * ```ts
40427
40539
  * // Select all users and their pets
40428
- * const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
40540
+ * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
40429
40541
  * .from(users)
40430
40542
  * .rightJoin(pets, eq(users.id, pets.ownerId))
40431
40543
  *
40432
40544
  * // Select userId and petId
40433
- * const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
40545
+ * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
40434
40546
  * userId: users.id,
40435
40547
  * petId: pets.id,
40436
40548
  * })
@@ -40438,7 +40550,7 @@ var init_select4 = __esm({
40438
40550
  * .rightJoin(pets, eq(users.id, pets.ownerId))
40439
40551
  *
40440
40552
  * // Select userId and petId with use index hint
40441
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
40553
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
40442
40554
  * userId: users.id,
40443
40555
  * petId: pets.id,
40444
40556
  * })
@@ -40448,7 +40560,7 @@ var init_select4 = __esm({
40448
40560
  * })
40449
40561
  * ```
40450
40562
  */
40451
- __publicField(this, "rightJoin", this.createJoin("right"));
40563
+ __publicField(this, "rightJoin", this.createJoin("right", false));
40452
40564
  /**
40453
40565
  * Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
40454
40566
  *
@@ -40458,17 +40570,18 @@ var init_select4 = __esm({
40458
40570
  *
40459
40571
  * @param table the table to join.
40460
40572
  * @param on the `on` clause.
40573
+ * @param onIndex index hint.
40461
40574
  *
40462
40575
  * @example
40463
40576
  *
40464
40577
  * ```ts
40465
40578
  * // Select all users and their pets
40466
- * const usersWithPets: { user: User; pets: Pet }[] = await db.select()
40579
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
40467
40580
  * .from(users)
40468
40581
  * .innerJoin(pets, eq(users.id, pets.ownerId))
40469
40582
  *
40470
40583
  * // Select userId and petId
40471
- * const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
40584
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
40472
40585
  * userId: users.id,
40473
40586
  * petId: pets.id,
40474
40587
  * })
@@ -40476,7 +40589,7 @@ var init_select4 = __esm({
40476
40589
  * .innerJoin(pets, eq(users.id, pets.ownerId))
40477
40590
  *
40478
40591
  * // Select userId and petId with use index hint
40479
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
40592
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
40480
40593
  * userId: users.id,
40481
40594
  * petId: pets.id,
40482
40595
  * })
@@ -40486,45 +40599,70 @@ var init_select4 = __esm({
40486
40599
  * })
40487
40600
  * ```
40488
40601
  */
40489
- __publicField(this, "innerJoin", this.createJoin("inner"));
40602
+ __publicField(this, "innerJoin", this.createJoin("inner", false));
40490
40603
  /**
40491
- * Executes a `full join` operation by combining rows from two tables into a new table.
40604
+ * Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
40492
40605
  *
40493
- * 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.
40606
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
40494
40607
  *
40495
- * See docs: {@link https://orm.drizzle.team/docs/joins#full-join}
40608
+ * 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.
40496
40609
  *
40497
- * @param table the table to join.
40610
+ * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
40611
+ *
40612
+ * @param table the subquery to join.
40498
40613
  * @param on the `on` clause.
40614
+ */
40615
+ __publicField(this, "innerJoinLateral", this.createJoin("inner", true));
40616
+ /**
40617
+ * Executes a `cross join` operation by combining rows from two tables into a new table.
40618
+ *
40619
+ * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
40620
+ *
40621
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
40622
+ *
40623
+ * @param table the table to join.
40624
+ * @param onIndex index hint.
40499
40625
  *
40500
40626
  * @example
40501
40627
  *
40502
40628
  * ```ts
40503
- * // Select all users and their pets
40504
- * const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
40629
+ * // Select all users, each user with every pet
40630
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
40505
40631
  * .from(users)
40506
- * .fullJoin(pets, eq(users.id, pets.ownerId))
40632
+ * .crossJoin(pets)
40507
40633
  *
40508
40634
  * // Select userId and petId
40509
- * const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
40635
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
40510
40636
  * userId: users.id,
40511
40637
  * petId: pets.id,
40512
40638
  * })
40513
40639
  * .from(users)
40514
- * .fullJoin(pets, eq(users.id, pets.ownerId))
40640
+ * .crossJoin(pets)
40515
40641
  *
40516
40642
  * // Select userId and petId with use index hint
40517
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
40643
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
40518
40644
  * userId: users.id,
40519
40645
  * petId: pets.id,
40520
40646
  * })
40521
40647
  * .from(users)
40522
- * .leftJoin(pets, eq(users.id, pets.ownerId), {
40648
+ * .crossJoin(pets, {
40523
40649
  * useIndex: ['pets_owner_id_index']
40524
40650
  * })
40525
40651
  * ```
40526
40652
  */
40527
- __publicField(this, "fullJoin", this.createJoin("full"));
40653
+ __publicField(this, "crossJoin", this.createJoin("cross", false));
40654
+ /**
40655
+ * Executes a `cross join lateral` operation by combining rows from two queries into a new table.
40656
+ *
40657
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
40658
+ *
40659
+ * Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
40660
+ *
40661
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
40662
+ *
40663
+ * @param table the query to join.
40664
+ */
40665
+ __publicField(this, "crossJoinLateral", this.createJoin("cross", true));
40528
40666
  /**
40529
40667
  * Adds `union` set operator to the query.
40530
40668
  *
@@ -40730,8 +40868,11 @@ var init_select4 = __esm({
40730
40868
  this.tableName = getTableLikeName(table6);
40731
40869
  this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
40732
40870
  }
40733
- createJoin(joinType) {
40734
- return (table6, on, onIndex) => {
40871
+ createJoin(joinType, lateral) {
40872
+ return (table6, a, b) => {
40873
+ const isCrossJoin = joinType === "cross";
40874
+ let on = isCrossJoin ? void 0 : a;
40875
+ const onIndex = isCrossJoin ? a : b;
40735
40876
  const baseTableName = this.tableName;
40736
40877
  const tableName = getTableLikeName(table6);
40737
40878
  if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
@@ -40773,7 +40914,7 @@ var init_select4 = __esm({
40773
40914
  ignoreIndex = convertIndexToString(toArray(onIndex.ignoreIndex));
40774
40915
  }
40775
40916
  }
40776
- this.config.joins.push({ on, table: table6, joinType, alias: tableName, useIndex, forceIndex, ignoreIndex });
40917
+ this.config.joins.push({ on, table: table6, joinType, alias: tableName, useIndex, forceIndex, ignoreIndex, lateral });
40777
40918
  if (typeof tableName === "string") {
40778
40919
  switch (joinType) {
40779
40920
  case "left": {
@@ -40787,17 +40928,11 @@ var init_select4 = __esm({
40787
40928
  this.joinsNotNullableMap[tableName] = true;
40788
40929
  break;
40789
40930
  }
40931
+ case "cross":
40790
40932
  case "inner": {
40791
40933
  this.joinsNotNullableMap[tableName] = true;
40792
40934
  break;
40793
40935
  }
40794
- case "full": {
40795
- this.joinsNotNullableMap = Object.fromEntries(
40796
- Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
40797
- );
40798
- this.joinsNotNullableMap[tableName] = false;
40799
- break;
40800
- }
40801
40936
  }
40802
40937
  }
40803
40938
  return this;
@@ -45328,13 +45463,14 @@ var init_dialect4 = __esm({
45328
45463
  }
45329
45464
  const table22 = joinMeta.table;
45330
45465
  const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
45466
+ const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
45331
45467
  if (is(table22, SingleStoreTable)) {
45332
45468
  const tableName = table22[SingleStoreTable.Symbol.Name];
45333
45469
  const tableSchema = table22[SingleStoreTable.Symbol.Schema];
45334
45470
  const origTableName = table22[SingleStoreTable.Symbol.OriginalName];
45335
45471
  const alias = tableName === origTableName ? void 0 : joinMeta.alias;
45336
45472
  joinsArray.push(
45337
- 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}`
45473
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
45338
45474
  );
45339
45475
  } else if (is(table22, View3)) {
45340
45476
  const viewName = table22[ViewBaseConfig].name;
@@ -45342,11 +45478,11 @@ var init_dialect4 = __esm({
45342
45478
  const origViewName = table22[ViewBaseConfig].originalName;
45343
45479
  const alias = viewName === origViewName ? void 0 : joinMeta.alias;
45344
45480
  joinsArray.push(
45345
- 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}`
45481
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
45346
45482
  );
45347
45483
  } else {
45348
45484
  joinsArray.push(
45349
- sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22} on ${joinMeta.on}`
45485
+ sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}${onSql}`
45350
45486
  );
45351
45487
  }
45352
45488
  if (index6 < joins.length - 1) {
@@ -45366,7 +45502,7 @@ var init_dialect4 = __esm({
45366
45502
  const { config, strength } = lockingClause;
45367
45503
  lockingClausesSql = sql` for ${sql.raw(strength)}`;
45368
45504
  if (config.noWait) {
45369
- lockingClausesSql.append(sql` no wait`);
45505
+ lockingClausesSql.append(sql` nowait`);
45370
45506
  } else if (config.skipLocked) {
45371
45507
  lockingClausesSql.append(sql` skip locked`);
45372
45508
  }
@@ -45806,12 +45942,12 @@ var init_select5 = __esm({
45806
45942
  *
45807
45943
  * ```ts
45808
45944
  * // Select all users and their pets
45809
- * const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
45945
+ * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
45810
45946
  * .from(users)
45811
45947
  * .leftJoin(pets, eq(users.id, pets.ownerId))
45812
45948
  *
45813
45949
  * // Select userId and petId
45814
- * const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
45950
+ * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
45815
45951
  * userId: users.id,
45816
45952
  * petId: pets.id,
45817
45953
  * })
@@ -45819,7 +45955,20 @@ var init_select5 = __esm({
45819
45955
  * .leftJoin(pets, eq(users.id, pets.ownerId))
45820
45956
  * ```
45821
45957
  */
45822
- __publicField(this, "leftJoin", this.createJoin("left"));
45958
+ __publicField(this, "leftJoin", this.createJoin("left", false));
45959
+ /**
45960
+ * Executes a `left join lateral` operation by adding subquery to the current query.
45961
+ *
45962
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
45963
+ *
45964
+ * 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.
45965
+ *
45966
+ * See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
45967
+ *
45968
+ * @param table the subquery to join.
45969
+ * @param on the `on` clause.
45970
+ */
45971
+ __publicField(this, "leftJoinLateral", this.createJoin("left", true));
45823
45972
  /**
45824
45973
  * Executes a `right join` operation by adding another table to the current query.
45825
45974
  *
@@ -45834,12 +45983,12 @@ var init_select5 = __esm({
45834
45983
  *
45835
45984
  * ```ts
45836
45985
  * // Select all users and their pets
45837
- * const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
45986
+ * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
45838
45987
  * .from(users)
45839
45988
  * .rightJoin(pets, eq(users.id, pets.ownerId))
45840
45989
  *
45841
45990
  * // Select userId and petId
45842
- * const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
45991
+ * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
45843
45992
  * userId: users.id,
45844
45993
  * petId: pets.id,
45845
45994
  * })
@@ -45847,7 +45996,7 @@ var init_select5 = __esm({
45847
45996
  * .rightJoin(pets, eq(users.id, pets.ownerId))
45848
45997
  * ```
45849
45998
  */
45850
- __publicField(this, "rightJoin", this.createJoin("right"));
45999
+ __publicField(this, "rightJoin", this.createJoin("right", false));
45851
46000
  /**
45852
46001
  * Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
45853
46002
  *
@@ -45862,12 +46011,12 @@ var init_select5 = __esm({
45862
46011
  *
45863
46012
  * ```ts
45864
46013
  * // Select all users and their pets
45865
- * const usersWithPets: { user: User; pets: Pet }[] = await db.select()
46014
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
45866
46015
  * .from(users)
45867
46016
  * .innerJoin(pets, eq(users.id, pets.ownerId))
45868
46017
  *
45869
46018
  * // Select userId and petId
45870
- * const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
46019
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
45871
46020
  * userId: users.id,
45872
46021
  * petId: pets.id,
45873
46022
  * })
@@ -45875,7 +46024,20 @@ var init_select5 = __esm({
45875
46024
  * .innerJoin(pets, eq(users.id, pets.ownerId))
45876
46025
  * ```
45877
46026
  */
45878
- __publicField(this, "innerJoin", this.createJoin("inner"));
46027
+ __publicField(this, "innerJoin", this.createJoin("inner", false));
46028
+ /**
46029
+ * Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
46030
+ *
46031
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
46032
+ *
46033
+ * 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.
46034
+ *
46035
+ * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
46036
+ *
46037
+ * @param table the subquery to join.
46038
+ * @param on the `on` clause.
46039
+ */
46040
+ __publicField(this, "innerJoinLateral", this.createJoin("inner", true));
45879
46041
  /**
45880
46042
  * Executes a `full join` operation by combining rows from two tables into a new table.
45881
46043
  *
@@ -45890,12 +46052,12 @@ var init_select5 = __esm({
45890
46052
  *
45891
46053
  * ```ts
45892
46054
  * // Select all users and their pets
45893
- * const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
46055
+ * const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
45894
46056
  * .from(users)
45895
46057
  * .fullJoin(pets, eq(users.id, pets.ownerId))
45896
46058
  *
45897
46059
  * // Select userId and petId
45898
- * const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
46060
+ * const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
45899
46061
  * userId: users.id,
45900
46062
  * petId: pets.id,
45901
46063
  * })
@@ -45903,7 +46065,46 @@ var init_select5 = __esm({
45903
46065
  * .fullJoin(pets, eq(users.id, pets.ownerId))
45904
46066
  * ```
45905
46067
  */
45906
- __publicField(this, "fullJoin", this.createJoin("full"));
46068
+ __publicField(this, "fullJoin", this.createJoin("full", false));
46069
+ /**
46070
+ * Executes a `cross join` operation by combining rows from two tables into a new table.
46071
+ *
46072
+ * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
46073
+ *
46074
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
46075
+ *
46076
+ * @param table the table to join.
46077
+ *
46078
+ * @example
46079
+ *
46080
+ * ```ts
46081
+ * // Select all users, each user with every pet
46082
+ * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
46083
+ * .from(users)
46084
+ * .crossJoin(pets)
46085
+ *
46086
+ * // Select userId and petId
46087
+ * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
46088
+ * userId: users.id,
46089
+ * petId: pets.id,
46090
+ * })
46091
+ * .from(users)
46092
+ * .crossJoin(pets)
46093
+ * ```
46094
+ */
46095
+ __publicField(this, "crossJoin", this.createJoin("cross", false));
46096
+ /**
46097
+ * Executes a `cross join lateral` operation by combining rows from two queries into a new table.
46098
+ *
46099
+ * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
46100
+ *
46101
+ * Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
46102
+ *
46103
+ * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
46104
+ *
46105
+ * @param table the query to join.
46106
+ */
46107
+ __publicField(this, "crossJoinLateral", this.createJoin("cross", true));
45907
46108
  /**
45908
46109
  * Adds `union` set operator to the query.
45909
46110
  *
@@ -46048,7 +46249,7 @@ var init_select5 = __esm({
46048
46249
  this.tableName = getTableLikeName(table6);
46049
46250
  this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
46050
46251
  }
46051
- createJoin(joinType) {
46252
+ createJoin(joinType, lateral) {
46052
46253
  return (table6, on) => {
46053
46254
  const baseTableName = this.tableName;
46054
46255
  const tableName = getTableLikeName(table6);
@@ -46077,7 +46278,7 @@ var init_select5 = __esm({
46077
46278
  if (!this.config.joins) {
46078
46279
  this.config.joins = [];
46079
46280
  }
46080
- this.config.joins.push({ on, table: table6, joinType, alias: tableName });
46281
+ this.config.joins.push({ on, table: table6, joinType, alias: tableName, lateral });
46081
46282
  if (typeof tableName === "string") {
46082
46283
  switch (joinType) {
46083
46284
  case "left": {
@@ -46091,6 +46292,7 @@ var init_select5 = __esm({
46091
46292
  this.joinsNotNullableMap[tableName] = true;
46092
46293
  break;
46093
46294
  }
46295
+ case "cross":
46094
46296
  case "inner": {
46095
46297
  this.joinsNotNullableMap[tableName] = true;
46096
46298
  break;