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.
- package/api.js +286 -84
- package/api.mjs +286 -84
- package/bin.cjs +1 -1
- package/package.json +1 -1
package/api.mjs
CHANGED
|
@@ -27250,13 +27250,14 @@ var init_dialect = __esm({
|
|
|
27250
27250
|
}
|
|
27251
27251
|
const table6 = joinMeta.table;
|
|
27252
27252
|
const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
|
|
27253
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
|
27253
27254
|
if (is(table6, PgTable)) {
|
|
27254
27255
|
const tableName = table6[PgTable.Symbol.Name];
|
|
27255
27256
|
const tableSchema = table6[PgTable.Symbol.Schema];
|
|
27256
27257
|
const origTableName = table6[PgTable.Symbol.OriginalName];
|
|
27257
27258
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
|
27258
27259
|
joinsArray.push(
|
|
27259
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}
|
|
27260
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
|
27260
27261
|
);
|
|
27261
27262
|
} else if (is(table6, View3)) {
|
|
27262
27263
|
const viewName = table6[ViewBaseConfig].name;
|
|
@@ -27264,11 +27265,11 @@ var init_dialect = __esm({
|
|
|
27264
27265
|
const origViewName = table6[ViewBaseConfig].originalName;
|
|
27265
27266
|
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
|
27266
27267
|
joinsArray.push(
|
|
27267
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}
|
|
27268
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
|
27268
27269
|
);
|
|
27269
27270
|
} else {
|
|
27270
27271
|
joinsArray.push(
|
|
27271
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table6}
|
|
27272
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table6}${onSql}`
|
|
27272
27273
|
);
|
|
27273
27274
|
}
|
|
27274
27275
|
if (index6 < joins.length - 1) {
|
|
@@ -27347,7 +27348,7 @@ var init_dialect = __esm({
|
|
|
27347
27348
|
);
|
|
27348
27349
|
}
|
|
27349
27350
|
if (lockingClause.config.noWait) {
|
|
27350
|
-
clauseSql.append(sql`
|
|
27351
|
+
clauseSql.append(sql` nowait`);
|
|
27351
27352
|
} else if (lockingClause.config.skipLocked) {
|
|
27352
27353
|
clauseSql.append(sql` skip locked`);
|
|
27353
27354
|
}
|
|
@@ -27976,12 +27977,12 @@ var init_select2 = __esm({
|
|
|
27976
27977
|
*
|
|
27977
27978
|
* ```ts
|
|
27978
27979
|
* // Select all users and their pets
|
|
27979
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
|
27980
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
|
27980
27981
|
* .from(users)
|
|
27981
27982
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
27982
27983
|
*
|
|
27983
27984
|
* // Select userId and petId
|
|
27984
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
27985
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
27985
27986
|
* userId: users.id,
|
|
27986
27987
|
* petId: pets.id,
|
|
27987
27988
|
* })
|
|
@@ -27989,7 +27990,20 @@ var init_select2 = __esm({
|
|
|
27989
27990
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
27990
27991
|
* ```
|
|
27991
27992
|
*/
|
|
27992
|
-
__publicField(this, "leftJoin", this.createJoin("left"));
|
|
27993
|
+
__publicField(this, "leftJoin", this.createJoin("left", false));
|
|
27994
|
+
/**
|
|
27995
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
|
27996
|
+
*
|
|
27997
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
27998
|
+
*
|
|
27999
|
+
* 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.
|
|
28000
|
+
*
|
|
28001
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
|
28002
|
+
*
|
|
28003
|
+
* @param table the subquery to join.
|
|
28004
|
+
* @param on the `on` clause.
|
|
28005
|
+
*/
|
|
28006
|
+
__publicField(this, "leftJoinLateral", this.createJoin("left", true));
|
|
27993
28007
|
/**
|
|
27994
28008
|
* Executes a `right join` operation by adding another table to the current query.
|
|
27995
28009
|
*
|
|
@@ -28004,12 +28018,12 @@ var init_select2 = __esm({
|
|
|
28004
28018
|
*
|
|
28005
28019
|
* ```ts
|
|
28006
28020
|
* // Select all users and their pets
|
|
28007
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
|
28021
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
|
28008
28022
|
* .from(users)
|
|
28009
28023
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
28010
28024
|
*
|
|
28011
28025
|
* // Select userId and petId
|
|
28012
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
|
28026
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
|
28013
28027
|
* userId: users.id,
|
|
28014
28028
|
* petId: pets.id,
|
|
28015
28029
|
* })
|
|
@@ -28017,7 +28031,7 @@ var init_select2 = __esm({
|
|
|
28017
28031
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
28018
28032
|
* ```
|
|
28019
28033
|
*/
|
|
28020
|
-
__publicField(this, "rightJoin", this.createJoin("right"));
|
|
28034
|
+
__publicField(this, "rightJoin", this.createJoin("right", false));
|
|
28021
28035
|
/**
|
|
28022
28036
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
|
28023
28037
|
*
|
|
@@ -28032,12 +28046,12 @@ var init_select2 = __esm({
|
|
|
28032
28046
|
*
|
|
28033
28047
|
* ```ts
|
|
28034
28048
|
* // Select all users and their pets
|
|
28035
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
|
28049
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
28036
28050
|
* .from(users)
|
|
28037
28051
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
28038
28052
|
*
|
|
28039
28053
|
* // Select userId and petId
|
|
28040
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
|
28054
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
28041
28055
|
* userId: users.id,
|
|
28042
28056
|
* petId: pets.id,
|
|
28043
28057
|
* })
|
|
@@ -28045,7 +28059,20 @@ var init_select2 = __esm({
|
|
|
28045
28059
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
28046
28060
|
* ```
|
|
28047
28061
|
*/
|
|
28048
|
-
__publicField(this, "innerJoin", this.createJoin("inner"));
|
|
28062
|
+
__publicField(this, "innerJoin", this.createJoin("inner", false));
|
|
28063
|
+
/**
|
|
28064
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
|
28065
|
+
*
|
|
28066
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
28067
|
+
*
|
|
28068
|
+
* 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.
|
|
28069
|
+
*
|
|
28070
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
|
28071
|
+
*
|
|
28072
|
+
* @param table the subquery to join.
|
|
28073
|
+
* @param on the `on` clause.
|
|
28074
|
+
*/
|
|
28075
|
+
__publicField(this, "innerJoinLateral", this.createJoin("inner", true));
|
|
28049
28076
|
/**
|
|
28050
28077
|
* Executes a `full join` operation by combining rows from two tables into a new table.
|
|
28051
28078
|
*
|
|
@@ -28060,12 +28087,12 @@ var init_select2 = __esm({
|
|
|
28060
28087
|
*
|
|
28061
28088
|
* ```ts
|
|
28062
28089
|
* // Select all users and their pets
|
|
28063
|
-
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
|
28090
|
+
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
|
28064
28091
|
* .from(users)
|
|
28065
28092
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
|
28066
28093
|
*
|
|
28067
28094
|
* // Select userId and petId
|
|
28068
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
|
28095
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
|
28069
28096
|
* userId: users.id,
|
|
28070
28097
|
* petId: pets.id,
|
|
28071
28098
|
* })
|
|
@@ -28073,7 +28100,46 @@ var init_select2 = __esm({
|
|
|
28073
28100
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
|
28074
28101
|
* ```
|
|
28075
28102
|
*/
|
|
28076
|
-
__publicField(this, "fullJoin", this.createJoin("full"));
|
|
28103
|
+
__publicField(this, "fullJoin", this.createJoin("full", false));
|
|
28104
|
+
/**
|
|
28105
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
|
28106
|
+
*
|
|
28107
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
|
28108
|
+
*
|
|
28109
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
|
28110
|
+
*
|
|
28111
|
+
* @param table the table to join.
|
|
28112
|
+
*
|
|
28113
|
+
* @example
|
|
28114
|
+
*
|
|
28115
|
+
* ```ts
|
|
28116
|
+
* // Select all users, each user with every pet
|
|
28117
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
28118
|
+
* .from(users)
|
|
28119
|
+
* .crossJoin(pets)
|
|
28120
|
+
*
|
|
28121
|
+
* // Select userId and petId
|
|
28122
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
28123
|
+
* userId: users.id,
|
|
28124
|
+
* petId: pets.id,
|
|
28125
|
+
* })
|
|
28126
|
+
* .from(users)
|
|
28127
|
+
* .crossJoin(pets)
|
|
28128
|
+
* ```
|
|
28129
|
+
*/
|
|
28130
|
+
__publicField(this, "crossJoin", this.createJoin("cross", false));
|
|
28131
|
+
/**
|
|
28132
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
|
28133
|
+
*
|
|
28134
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
28135
|
+
*
|
|
28136
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
|
28137
|
+
*
|
|
28138
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
|
28139
|
+
*
|
|
28140
|
+
* @param table the query to join.
|
|
28141
|
+
*/
|
|
28142
|
+
__publicField(this, "crossJoinLateral", this.createJoin("cross", true));
|
|
28077
28143
|
/**
|
|
28078
28144
|
* Adds `union` set operator to the query.
|
|
28079
28145
|
*
|
|
@@ -28276,7 +28342,7 @@ var init_select2 = __esm({
|
|
|
28276
28342
|
this.tableName = getTableLikeName(table6);
|
|
28277
28343
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
|
28278
28344
|
}
|
|
28279
|
-
createJoin(joinType) {
|
|
28345
|
+
createJoin(joinType, lateral) {
|
|
28280
28346
|
return (table6, on) => {
|
|
28281
28347
|
const baseTableName = this.tableName;
|
|
28282
28348
|
const tableName = getTableLikeName(table6);
|
|
@@ -28305,7 +28371,7 @@ var init_select2 = __esm({
|
|
|
28305
28371
|
if (!this.config.joins) {
|
|
28306
28372
|
this.config.joins = [];
|
|
28307
28373
|
}
|
|
28308
|
-
this.config.joins.push({ on, table: table6, joinType, alias: tableName });
|
|
28374
|
+
this.config.joins.push({ on, table: table6, joinType, alias: tableName, lateral });
|
|
28309
28375
|
if (typeof tableName === "string") {
|
|
28310
28376
|
switch (joinType) {
|
|
28311
28377
|
case "left": {
|
|
@@ -28319,6 +28385,7 @@ var init_select2 = __esm({
|
|
|
28319
28385
|
this.joinsNotNullableMap[tableName] = true;
|
|
28320
28386
|
break;
|
|
28321
28387
|
}
|
|
28388
|
+
case "cross":
|
|
28322
28389
|
case "inner": {
|
|
28323
28390
|
this.joinsNotNullableMap[tableName] = true;
|
|
28324
28391
|
break;
|
|
@@ -33499,17 +33566,18 @@ var init_dialect2 = __esm({
|
|
|
33499
33566
|
joinsArray.push(sql` `);
|
|
33500
33567
|
}
|
|
33501
33568
|
const table6 = joinMeta.table;
|
|
33569
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
|
33502
33570
|
if (is(table6, SQLiteTable)) {
|
|
33503
33571
|
const tableName = table6[SQLiteTable.Symbol.Name];
|
|
33504
33572
|
const tableSchema = table6[SQLiteTable.Symbol.Schema];
|
|
33505
33573
|
const origTableName = table6[SQLiteTable.Symbol.OriginalName];
|
|
33506
33574
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
|
33507
33575
|
joinsArray.push(
|
|
33508
|
-
sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}
|
|
33576
|
+
sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
|
33509
33577
|
);
|
|
33510
33578
|
} else {
|
|
33511
33579
|
joinsArray.push(
|
|
33512
|
-
sql`${sql.raw(joinMeta.joinType)} join ${table6}
|
|
33580
|
+
sql`${sql.raw(joinMeta.joinType)} join ${table6}${onSql}`
|
|
33513
33581
|
);
|
|
33514
33582
|
}
|
|
33515
33583
|
if (index6 < joins.length - 1) {
|
|
@@ -34215,12 +34283,12 @@ var init_select3 = __esm({
|
|
|
34215
34283
|
*
|
|
34216
34284
|
* ```ts
|
|
34217
34285
|
* // Select all users and their pets
|
|
34218
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
|
34286
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
|
34219
34287
|
* .from(users)
|
|
34220
34288
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
34221
34289
|
*
|
|
34222
34290
|
* // Select userId and petId
|
|
34223
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
34291
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
34224
34292
|
* userId: users.id,
|
|
34225
34293
|
* petId: pets.id,
|
|
34226
34294
|
* })
|
|
@@ -34243,12 +34311,12 @@ var init_select3 = __esm({
|
|
|
34243
34311
|
*
|
|
34244
34312
|
* ```ts
|
|
34245
34313
|
* // Select all users and their pets
|
|
34246
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
|
34314
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
|
34247
34315
|
* .from(users)
|
|
34248
34316
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
34249
34317
|
*
|
|
34250
34318
|
* // Select userId and petId
|
|
34251
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
|
34319
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
|
34252
34320
|
* userId: users.id,
|
|
34253
34321
|
* petId: pets.id,
|
|
34254
34322
|
* })
|
|
@@ -34271,12 +34339,12 @@ var init_select3 = __esm({
|
|
|
34271
34339
|
*
|
|
34272
34340
|
* ```ts
|
|
34273
34341
|
* // Select all users and their pets
|
|
34274
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
|
34342
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
34275
34343
|
* .from(users)
|
|
34276
34344
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
34277
34345
|
*
|
|
34278
34346
|
* // Select userId and petId
|
|
34279
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
|
34347
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
34280
34348
|
* userId: users.id,
|
|
34281
34349
|
* petId: pets.id,
|
|
34282
34350
|
* })
|
|
@@ -34299,12 +34367,12 @@ var init_select3 = __esm({
|
|
|
34299
34367
|
*
|
|
34300
34368
|
* ```ts
|
|
34301
34369
|
* // Select all users and their pets
|
|
34302
|
-
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
|
34370
|
+
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
|
34303
34371
|
* .from(users)
|
|
34304
34372
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
|
34305
34373
|
*
|
|
34306
34374
|
* // Select userId and petId
|
|
34307
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
|
34375
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
|
34308
34376
|
* userId: users.id,
|
|
34309
34377
|
* petId: pets.id,
|
|
34310
34378
|
* })
|
|
@@ -34313,6 +34381,33 @@ var init_select3 = __esm({
|
|
|
34313
34381
|
* ```
|
|
34314
34382
|
*/
|
|
34315
34383
|
__publicField(this, "fullJoin", this.createJoin("full"));
|
|
34384
|
+
/**
|
|
34385
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
|
34386
|
+
*
|
|
34387
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
|
34388
|
+
*
|
|
34389
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
|
34390
|
+
*
|
|
34391
|
+
* @param table the table to join.
|
|
34392
|
+
*
|
|
34393
|
+
* @example
|
|
34394
|
+
*
|
|
34395
|
+
* ```ts
|
|
34396
|
+
* // Select all users, each user with every pet
|
|
34397
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
34398
|
+
* .from(users)
|
|
34399
|
+
* .crossJoin(pets)
|
|
34400
|
+
*
|
|
34401
|
+
* // Select userId and petId
|
|
34402
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
34403
|
+
* userId: users.id,
|
|
34404
|
+
* petId: pets.id,
|
|
34405
|
+
* })
|
|
34406
|
+
* .from(users)
|
|
34407
|
+
* .crossJoin(pets)
|
|
34408
|
+
* ```
|
|
34409
|
+
*/
|
|
34410
|
+
__publicField(this, "crossJoin", this.createJoin("cross"));
|
|
34316
34411
|
/**
|
|
34317
34412
|
* Adds `union` set operator to the query.
|
|
34318
34413
|
*
|
|
@@ -34476,6 +34571,7 @@ var init_select3 = __esm({
|
|
|
34476
34571
|
this.joinsNotNullableMap[tableName] = true;
|
|
34477
34572
|
break;
|
|
34478
34573
|
}
|
|
34574
|
+
case "cross":
|
|
34479
34575
|
case "inner": {
|
|
34480
34576
|
this.joinsNotNullableMap[tableName] = true;
|
|
34481
34577
|
break;
|
|
@@ -39341,6 +39437,7 @@ var init_dialect3 = __esm({
|
|
|
39341
39437
|
}
|
|
39342
39438
|
const table22 = joinMeta.table;
|
|
39343
39439
|
const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
|
|
39440
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
|
39344
39441
|
if (is(table22, MySqlTable)) {
|
|
39345
39442
|
const tableName = table22[MySqlTable.Symbol.Name];
|
|
39346
39443
|
const tableSchema = table22[MySqlTable.Symbol.Schema];
|
|
@@ -39350,7 +39447,7 @@ var init_dialect3 = __esm({
|
|
|
39350
39447
|
const forceIndexSql2 = this.buildIndex({ indexes: joinMeta.forceIndex, indexFor: "FORCE" });
|
|
39351
39448
|
const ignoreIndexSql2 = this.buildIndex({ indexes: joinMeta.ignoreIndex, indexFor: "IGNORE" });
|
|
39352
39449
|
joinsArray.push(
|
|
39353
|
-
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)}`}
|
|
39450
|
+
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}`
|
|
39354
39451
|
);
|
|
39355
39452
|
} else if (is(table22, View3)) {
|
|
39356
39453
|
const viewName = table22[ViewBaseConfig].name;
|
|
@@ -39358,11 +39455,11 @@ var init_dialect3 = __esm({
|
|
|
39358
39455
|
const origViewName = table22[ViewBaseConfig].originalName;
|
|
39359
39456
|
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
|
39360
39457
|
joinsArray.push(
|
|
39361
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}
|
|
39458
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
|
39362
39459
|
);
|
|
39363
39460
|
} else {
|
|
39364
39461
|
joinsArray.push(
|
|
39365
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}
|
|
39462
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}${onSql}`
|
|
39366
39463
|
);
|
|
39367
39464
|
}
|
|
39368
39465
|
if (index6 < joins.length - 1) {
|
|
@@ -39385,7 +39482,7 @@ var init_dialect3 = __esm({
|
|
|
39385
39482
|
const { config, strength } = lockingClause;
|
|
39386
39483
|
lockingClausesSql = sql` for ${sql.raw(strength)}`;
|
|
39387
39484
|
if (config.noWait) {
|
|
39388
|
-
lockingClausesSql.append(sql`
|
|
39485
|
+
lockingClausesSql.append(sql` nowait`);
|
|
39389
39486
|
} else if (config.skipLocked) {
|
|
39390
39487
|
lockingClausesSql.append(sql` skip locked`);
|
|
39391
39488
|
}
|
|
@@ -40387,17 +40484,18 @@ var init_select4 = __esm({
|
|
|
40387
40484
|
*
|
|
40388
40485
|
* @param table the table to join.
|
|
40389
40486
|
* @param on the `on` clause.
|
|
40487
|
+
* @param onIndex index hint.
|
|
40390
40488
|
*
|
|
40391
40489
|
* @example
|
|
40392
40490
|
*
|
|
40393
40491
|
* ```ts
|
|
40394
40492
|
* // Select all users and their pets
|
|
40395
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
|
40493
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
|
40396
40494
|
* .from(users)
|
|
40397
40495
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
40398
40496
|
*
|
|
40399
40497
|
* // Select userId and petId
|
|
40400
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
40498
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
40401
40499
|
* userId: users.id,
|
|
40402
40500
|
* petId: pets.id,
|
|
40403
40501
|
* })
|
|
@@ -40405,7 +40503,7 @@ var init_select4 = __esm({
|
|
|
40405
40503
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
40406
40504
|
*
|
|
40407
40505
|
* // Select userId and petId with use index hint
|
|
40408
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
40506
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
40409
40507
|
* userId: users.id,
|
|
40410
40508
|
* petId: pets.id,
|
|
40411
40509
|
* })
|
|
@@ -40415,7 +40513,20 @@ var init_select4 = __esm({
|
|
|
40415
40513
|
* })
|
|
40416
40514
|
* ```
|
|
40417
40515
|
*/
|
|
40418
|
-
__publicField(this, "leftJoin", this.createJoin("left"));
|
|
40516
|
+
__publicField(this, "leftJoin", this.createJoin("left", false));
|
|
40517
|
+
/**
|
|
40518
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
|
40519
|
+
*
|
|
40520
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
40521
|
+
*
|
|
40522
|
+
* 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.
|
|
40523
|
+
*
|
|
40524
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
|
40525
|
+
*
|
|
40526
|
+
* @param table the subquery to join.
|
|
40527
|
+
* @param on the `on` clause.
|
|
40528
|
+
*/
|
|
40529
|
+
__publicField(this, "leftJoinLateral", this.createJoin("left", true));
|
|
40419
40530
|
/**
|
|
40420
40531
|
* Executes a `right join` operation by adding another table to the current query.
|
|
40421
40532
|
*
|
|
@@ -40425,17 +40536,18 @@ var init_select4 = __esm({
|
|
|
40425
40536
|
*
|
|
40426
40537
|
* @param table the table to join.
|
|
40427
40538
|
* @param on the `on` clause.
|
|
40539
|
+
* @param onIndex index hint.
|
|
40428
40540
|
*
|
|
40429
40541
|
* @example
|
|
40430
40542
|
*
|
|
40431
40543
|
* ```ts
|
|
40432
40544
|
* // Select all users and their pets
|
|
40433
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
|
40545
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
|
40434
40546
|
* .from(users)
|
|
40435
40547
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
40436
40548
|
*
|
|
40437
40549
|
* // Select userId and petId
|
|
40438
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
|
40550
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
|
40439
40551
|
* userId: users.id,
|
|
40440
40552
|
* petId: pets.id,
|
|
40441
40553
|
* })
|
|
@@ -40443,7 +40555,7 @@ var init_select4 = __esm({
|
|
|
40443
40555
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
40444
40556
|
*
|
|
40445
40557
|
* // Select userId and petId with use index hint
|
|
40446
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
40558
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
40447
40559
|
* userId: users.id,
|
|
40448
40560
|
* petId: pets.id,
|
|
40449
40561
|
* })
|
|
@@ -40453,7 +40565,7 @@ var init_select4 = __esm({
|
|
|
40453
40565
|
* })
|
|
40454
40566
|
* ```
|
|
40455
40567
|
*/
|
|
40456
|
-
__publicField(this, "rightJoin", this.createJoin("right"));
|
|
40568
|
+
__publicField(this, "rightJoin", this.createJoin("right", false));
|
|
40457
40569
|
/**
|
|
40458
40570
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
|
40459
40571
|
*
|
|
@@ -40463,17 +40575,18 @@ var init_select4 = __esm({
|
|
|
40463
40575
|
*
|
|
40464
40576
|
* @param table the table to join.
|
|
40465
40577
|
* @param on the `on` clause.
|
|
40578
|
+
* @param onIndex index hint.
|
|
40466
40579
|
*
|
|
40467
40580
|
* @example
|
|
40468
40581
|
*
|
|
40469
40582
|
* ```ts
|
|
40470
40583
|
* // Select all users and their pets
|
|
40471
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
|
40584
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
40472
40585
|
* .from(users)
|
|
40473
40586
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
40474
40587
|
*
|
|
40475
40588
|
* // Select userId and petId
|
|
40476
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
|
40589
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
40477
40590
|
* userId: users.id,
|
|
40478
40591
|
* petId: pets.id,
|
|
40479
40592
|
* })
|
|
@@ -40481,7 +40594,7 @@ var init_select4 = __esm({
|
|
|
40481
40594
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
40482
40595
|
*
|
|
40483
40596
|
* // Select userId and petId with use index hint
|
|
40484
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
40597
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
40485
40598
|
* userId: users.id,
|
|
40486
40599
|
* petId: pets.id,
|
|
40487
40600
|
* })
|
|
@@ -40491,45 +40604,70 @@ var init_select4 = __esm({
|
|
|
40491
40604
|
* })
|
|
40492
40605
|
* ```
|
|
40493
40606
|
*/
|
|
40494
|
-
__publicField(this, "innerJoin", this.createJoin("inner"));
|
|
40607
|
+
__publicField(this, "innerJoin", this.createJoin("inner", false));
|
|
40495
40608
|
/**
|
|
40496
|
-
* Executes
|
|
40609
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
|
40497
40610
|
*
|
|
40498
|
-
*
|
|
40611
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
40499
40612
|
*
|
|
40500
|
-
*
|
|
40613
|
+
* 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.
|
|
40501
40614
|
*
|
|
40502
|
-
*
|
|
40615
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
|
40616
|
+
*
|
|
40617
|
+
* @param table the subquery to join.
|
|
40503
40618
|
* @param on the `on` clause.
|
|
40619
|
+
*/
|
|
40620
|
+
__publicField(this, "innerJoinLateral", this.createJoin("inner", true));
|
|
40621
|
+
/**
|
|
40622
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
|
40623
|
+
*
|
|
40624
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
|
40625
|
+
*
|
|
40626
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
|
40627
|
+
*
|
|
40628
|
+
* @param table the table to join.
|
|
40629
|
+
* @param onIndex index hint.
|
|
40504
40630
|
*
|
|
40505
40631
|
* @example
|
|
40506
40632
|
*
|
|
40507
40633
|
* ```ts
|
|
40508
|
-
* // Select all users
|
|
40509
|
-
* const usersWithPets: { user: User
|
|
40634
|
+
* // Select all users, each user with every pet
|
|
40635
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
40510
40636
|
* .from(users)
|
|
40511
|
-
* .
|
|
40637
|
+
* .crossJoin(pets)
|
|
40512
40638
|
*
|
|
40513
40639
|
* // Select userId and petId
|
|
40514
|
-
* const usersIdsAndPetIds: { userId: number
|
|
40640
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
40515
40641
|
* userId: users.id,
|
|
40516
40642
|
* petId: pets.id,
|
|
40517
40643
|
* })
|
|
40518
40644
|
* .from(users)
|
|
40519
|
-
* .
|
|
40645
|
+
* .crossJoin(pets)
|
|
40520
40646
|
*
|
|
40521
40647
|
* // Select userId and petId with use index hint
|
|
40522
|
-
* const usersIdsAndPetIds: { userId: number; petId: number
|
|
40648
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
40523
40649
|
* userId: users.id,
|
|
40524
40650
|
* petId: pets.id,
|
|
40525
40651
|
* })
|
|
40526
40652
|
* .from(users)
|
|
40527
|
-
* .
|
|
40653
|
+
* .crossJoin(pets, {
|
|
40528
40654
|
* useIndex: ['pets_owner_id_index']
|
|
40529
40655
|
* })
|
|
40530
40656
|
* ```
|
|
40531
40657
|
*/
|
|
40532
|
-
__publicField(this, "
|
|
40658
|
+
__publicField(this, "crossJoin", this.createJoin("cross", false));
|
|
40659
|
+
/**
|
|
40660
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
|
40661
|
+
*
|
|
40662
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
40663
|
+
*
|
|
40664
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
|
40665
|
+
*
|
|
40666
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
|
40667
|
+
*
|
|
40668
|
+
* @param table the query to join.
|
|
40669
|
+
*/
|
|
40670
|
+
__publicField(this, "crossJoinLateral", this.createJoin("cross", true));
|
|
40533
40671
|
/**
|
|
40534
40672
|
* Adds `union` set operator to the query.
|
|
40535
40673
|
*
|
|
@@ -40735,8 +40873,11 @@ var init_select4 = __esm({
|
|
|
40735
40873
|
this.tableName = getTableLikeName(table6);
|
|
40736
40874
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
|
40737
40875
|
}
|
|
40738
|
-
createJoin(joinType) {
|
|
40739
|
-
return (table6,
|
|
40876
|
+
createJoin(joinType, lateral) {
|
|
40877
|
+
return (table6, a, b) => {
|
|
40878
|
+
const isCrossJoin = joinType === "cross";
|
|
40879
|
+
let on = isCrossJoin ? void 0 : a;
|
|
40880
|
+
const onIndex = isCrossJoin ? a : b;
|
|
40740
40881
|
const baseTableName = this.tableName;
|
|
40741
40882
|
const tableName = getTableLikeName(table6);
|
|
40742
40883
|
if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
|
|
@@ -40778,7 +40919,7 @@ var init_select4 = __esm({
|
|
|
40778
40919
|
ignoreIndex = convertIndexToString(toArray(onIndex.ignoreIndex));
|
|
40779
40920
|
}
|
|
40780
40921
|
}
|
|
40781
|
-
this.config.joins.push({ on, table: table6, joinType, alias: tableName, useIndex, forceIndex, ignoreIndex });
|
|
40922
|
+
this.config.joins.push({ on, table: table6, joinType, alias: tableName, useIndex, forceIndex, ignoreIndex, lateral });
|
|
40782
40923
|
if (typeof tableName === "string") {
|
|
40783
40924
|
switch (joinType) {
|
|
40784
40925
|
case "left": {
|
|
@@ -40792,17 +40933,11 @@ var init_select4 = __esm({
|
|
|
40792
40933
|
this.joinsNotNullableMap[tableName] = true;
|
|
40793
40934
|
break;
|
|
40794
40935
|
}
|
|
40936
|
+
case "cross":
|
|
40795
40937
|
case "inner": {
|
|
40796
40938
|
this.joinsNotNullableMap[tableName] = true;
|
|
40797
40939
|
break;
|
|
40798
40940
|
}
|
|
40799
|
-
case "full": {
|
|
40800
|
-
this.joinsNotNullableMap = Object.fromEntries(
|
|
40801
|
-
Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
|
|
40802
|
-
);
|
|
40803
|
-
this.joinsNotNullableMap[tableName] = false;
|
|
40804
|
-
break;
|
|
40805
|
-
}
|
|
40806
40941
|
}
|
|
40807
40942
|
}
|
|
40808
40943
|
return this;
|
|
@@ -45333,13 +45468,14 @@ var init_dialect4 = __esm({
|
|
|
45333
45468
|
}
|
|
45334
45469
|
const table22 = joinMeta.table;
|
|
45335
45470
|
const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
|
|
45471
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
|
45336
45472
|
if (is(table22, SingleStoreTable)) {
|
|
45337
45473
|
const tableName = table22[SingleStoreTable.Symbol.Name];
|
|
45338
45474
|
const tableSchema = table22[SingleStoreTable.Symbol.Schema];
|
|
45339
45475
|
const origTableName = table22[SingleStoreTable.Symbol.OriginalName];
|
|
45340
45476
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
|
45341
45477
|
joinsArray.push(
|
|
45342
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}
|
|
45478
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
|
45343
45479
|
);
|
|
45344
45480
|
} else if (is(table22, View3)) {
|
|
45345
45481
|
const viewName = table22[ViewBaseConfig].name;
|
|
@@ -45347,11 +45483,11 @@ var init_dialect4 = __esm({
|
|
|
45347
45483
|
const origViewName = table22[ViewBaseConfig].originalName;
|
|
45348
45484
|
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
|
45349
45485
|
joinsArray.push(
|
|
45350
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}
|
|
45486
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
|
45351
45487
|
);
|
|
45352
45488
|
} else {
|
|
45353
45489
|
joinsArray.push(
|
|
45354
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}
|
|
45490
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}${onSql}`
|
|
45355
45491
|
);
|
|
45356
45492
|
}
|
|
45357
45493
|
if (index6 < joins.length - 1) {
|
|
@@ -45371,7 +45507,7 @@ var init_dialect4 = __esm({
|
|
|
45371
45507
|
const { config, strength } = lockingClause;
|
|
45372
45508
|
lockingClausesSql = sql` for ${sql.raw(strength)}`;
|
|
45373
45509
|
if (config.noWait) {
|
|
45374
|
-
lockingClausesSql.append(sql`
|
|
45510
|
+
lockingClausesSql.append(sql` nowait`);
|
|
45375
45511
|
} else if (config.skipLocked) {
|
|
45376
45512
|
lockingClausesSql.append(sql` skip locked`);
|
|
45377
45513
|
}
|
|
@@ -45811,12 +45947,12 @@ var init_select5 = __esm({
|
|
|
45811
45947
|
*
|
|
45812
45948
|
* ```ts
|
|
45813
45949
|
* // Select all users and their pets
|
|
45814
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
|
45950
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
|
45815
45951
|
* .from(users)
|
|
45816
45952
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
45817
45953
|
*
|
|
45818
45954
|
* // Select userId and petId
|
|
45819
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
45955
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
45820
45956
|
* userId: users.id,
|
|
45821
45957
|
* petId: pets.id,
|
|
45822
45958
|
* })
|
|
@@ -45824,7 +45960,20 @@ var init_select5 = __esm({
|
|
|
45824
45960
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
45825
45961
|
* ```
|
|
45826
45962
|
*/
|
|
45827
|
-
__publicField(this, "leftJoin", this.createJoin("left"));
|
|
45963
|
+
__publicField(this, "leftJoin", this.createJoin("left", false));
|
|
45964
|
+
/**
|
|
45965
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
|
45966
|
+
*
|
|
45967
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
45968
|
+
*
|
|
45969
|
+
* 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.
|
|
45970
|
+
*
|
|
45971
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
|
45972
|
+
*
|
|
45973
|
+
* @param table the subquery to join.
|
|
45974
|
+
* @param on the `on` clause.
|
|
45975
|
+
*/
|
|
45976
|
+
__publicField(this, "leftJoinLateral", this.createJoin("left", true));
|
|
45828
45977
|
/**
|
|
45829
45978
|
* Executes a `right join` operation by adding another table to the current query.
|
|
45830
45979
|
*
|
|
@@ -45839,12 +45988,12 @@ var init_select5 = __esm({
|
|
|
45839
45988
|
*
|
|
45840
45989
|
* ```ts
|
|
45841
45990
|
* // Select all users and their pets
|
|
45842
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
|
45991
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
|
45843
45992
|
* .from(users)
|
|
45844
45993
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
45845
45994
|
*
|
|
45846
45995
|
* // Select userId and petId
|
|
45847
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
|
45996
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
|
45848
45997
|
* userId: users.id,
|
|
45849
45998
|
* petId: pets.id,
|
|
45850
45999
|
* })
|
|
@@ -45852,7 +46001,7 @@ var init_select5 = __esm({
|
|
|
45852
46001
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
45853
46002
|
* ```
|
|
45854
46003
|
*/
|
|
45855
|
-
__publicField(this, "rightJoin", this.createJoin("right"));
|
|
46004
|
+
__publicField(this, "rightJoin", this.createJoin("right", false));
|
|
45856
46005
|
/**
|
|
45857
46006
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
|
45858
46007
|
*
|
|
@@ -45867,12 +46016,12 @@ var init_select5 = __esm({
|
|
|
45867
46016
|
*
|
|
45868
46017
|
* ```ts
|
|
45869
46018
|
* // Select all users and their pets
|
|
45870
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
|
46019
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
45871
46020
|
* .from(users)
|
|
45872
46021
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
45873
46022
|
*
|
|
45874
46023
|
* // Select userId and petId
|
|
45875
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
|
46024
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
45876
46025
|
* userId: users.id,
|
|
45877
46026
|
* petId: pets.id,
|
|
45878
46027
|
* })
|
|
@@ -45880,7 +46029,20 @@ var init_select5 = __esm({
|
|
|
45880
46029
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
45881
46030
|
* ```
|
|
45882
46031
|
*/
|
|
45883
|
-
__publicField(this, "innerJoin", this.createJoin("inner"));
|
|
46032
|
+
__publicField(this, "innerJoin", this.createJoin("inner", false));
|
|
46033
|
+
/**
|
|
46034
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
|
46035
|
+
*
|
|
46036
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
46037
|
+
*
|
|
46038
|
+
* 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.
|
|
46039
|
+
*
|
|
46040
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
|
46041
|
+
*
|
|
46042
|
+
* @param table the subquery to join.
|
|
46043
|
+
* @param on the `on` clause.
|
|
46044
|
+
*/
|
|
46045
|
+
__publicField(this, "innerJoinLateral", this.createJoin("inner", true));
|
|
45884
46046
|
/**
|
|
45885
46047
|
* Executes a `full join` operation by combining rows from two tables into a new table.
|
|
45886
46048
|
*
|
|
@@ -45895,12 +46057,12 @@ var init_select5 = __esm({
|
|
|
45895
46057
|
*
|
|
45896
46058
|
* ```ts
|
|
45897
46059
|
* // Select all users and their pets
|
|
45898
|
-
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
|
46060
|
+
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
|
45899
46061
|
* .from(users)
|
|
45900
46062
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
|
45901
46063
|
*
|
|
45902
46064
|
* // Select userId and petId
|
|
45903
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
|
46065
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
|
45904
46066
|
* userId: users.id,
|
|
45905
46067
|
* petId: pets.id,
|
|
45906
46068
|
* })
|
|
@@ -45908,7 +46070,46 @@ var init_select5 = __esm({
|
|
|
45908
46070
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
|
45909
46071
|
* ```
|
|
45910
46072
|
*/
|
|
45911
|
-
__publicField(this, "fullJoin", this.createJoin("full"));
|
|
46073
|
+
__publicField(this, "fullJoin", this.createJoin("full", false));
|
|
46074
|
+
/**
|
|
46075
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
|
46076
|
+
*
|
|
46077
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
|
46078
|
+
*
|
|
46079
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
|
46080
|
+
*
|
|
46081
|
+
* @param table the table to join.
|
|
46082
|
+
*
|
|
46083
|
+
* @example
|
|
46084
|
+
*
|
|
46085
|
+
* ```ts
|
|
46086
|
+
* // Select all users, each user with every pet
|
|
46087
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
46088
|
+
* .from(users)
|
|
46089
|
+
* .crossJoin(pets)
|
|
46090
|
+
*
|
|
46091
|
+
* // Select userId and petId
|
|
46092
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
46093
|
+
* userId: users.id,
|
|
46094
|
+
* petId: pets.id,
|
|
46095
|
+
* })
|
|
46096
|
+
* .from(users)
|
|
46097
|
+
* .crossJoin(pets)
|
|
46098
|
+
* ```
|
|
46099
|
+
*/
|
|
46100
|
+
__publicField(this, "crossJoin", this.createJoin("cross", false));
|
|
46101
|
+
/**
|
|
46102
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
|
46103
|
+
*
|
|
46104
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
46105
|
+
*
|
|
46106
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
|
46107
|
+
*
|
|
46108
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
|
46109
|
+
*
|
|
46110
|
+
* @param table the query to join.
|
|
46111
|
+
*/
|
|
46112
|
+
__publicField(this, "crossJoinLateral", this.createJoin("cross", true));
|
|
45912
46113
|
/**
|
|
45913
46114
|
* Adds `union` set operator to the query.
|
|
45914
46115
|
*
|
|
@@ -46053,7 +46254,7 @@ var init_select5 = __esm({
|
|
|
46053
46254
|
this.tableName = getTableLikeName(table6);
|
|
46054
46255
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
|
46055
46256
|
}
|
|
46056
|
-
createJoin(joinType) {
|
|
46257
|
+
createJoin(joinType, lateral) {
|
|
46057
46258
|
return (table6, on) => {
|
|
46058
46259
|
const baseTableName = this.tableName;
|
|
46059
46260
|
const tableName = getTableLikeName(table6);
|
|
@@ -46082,7 +46283,7 @@ var init_select5 = __esm({
|
|
|
46082
46283
|
if (!this.config.joins) {
|
|
46083
46284
|
this.config.joins = [];
|
|
46084
46285
|
}
|
|
46085
|
-
this.config.joins.push({ on, table: table6, joinType, alias: tableName });
|
|
46286
|
+
this.config.joins.push({ on, table: table6, joinType, alias: tableName, lateral });
|
|
46086
46287
|
if (typeof tableName === "string") {
|
|
46087
46288
|
switch (joinType) {
|
|
46088
46289
|
case "left": {
|
|
@@ -46096,6 +46297,7 @@ var init_select5 = __esm({
|
|
|
46096
46297
|
this.joinsNotNullableMap[tableName] = true;
|
|
46097
46298
|
break;
|
|
46098
46299
|
}
|
|
46300
|
+
case "cross":
|
|
46099
46301
|
case "inner": {
|
|
46100
46302
|
this.joinsNotNullableMap[tableName] = true;
|
|
46101
46303
|
break;
|