drizzle-kit 0.31.0 → 0.31.1
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 +294 -92
- package/api.mjs +294 -92
- package/bin.cjs +6 -6
- package/package.json +1 -1
package/api.js
CHANGED
@@ -22662,7 +22662,7 @@ var version;
|
|
22662
22662
|
var init_version = __esm({
|
22663
22663
|
"../drizzle-orm/dist/version.js"() {
|
22664
22664
|
"use strict";
|
22665
|
-
version = "0.
|
22665
|
+
version = "0.43.1";
|
22666
22666
|
}
|
22667
22667
|
});
|
22668
22668
|
|
@@ -26645,13 +26645,14 @@ var init_dialect = __esm({
|
|
26645
26645
|
}
|
26646
26646
|
const table6 = joinMeta.table;
|
26647
26647
|
const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
|
26648
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
26648
26649
|
if (is(table6, PgTable)) {
|
26649
26650
|
const tableName = table6[PgTable.Symbol.Name];
|
26650
26651
|
const tableSchema = table6[PgTable.Symbol.Schema];
|
26651
26652
|
const origTableName = table6[PgTable.Symbol.OriginalName];
|
26652
26653
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
26653
26654
|
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)}`}
|
26655
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
26655
26656
|
);
|
26656
26657
|
} else if (is(table6, View3)) {
|
26657
26658
|
const viewName = table6[ViewBaseConfig].name;
|
@@ -26659,11 +26660,11 @@ var init_dialect = __esm({
|
|
26659
26660
|
const origViewName = table6[ViewBaseConfig].originalName;
|
26660
26661
|
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
26661
26662
|
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)}`}
|
26663
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
26663
26664
|
);
|
26664
26665
|
} else {
|
26665
26666
|
joinsArray.push(
|
26666
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table6}
|
26667
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table6}${onSql}`
|
26667
26668
|
);
|
26668
26669
|
}
|
26669
26670
|
if (index6 < joins.length - 1) {
|
@@ -26742,7 +26743,7 @@ var init_dialect = __esm({
|
|
26742
26743
|
);
|
26743
26744
|
}
|
26744
26745
|
if (lockingClause.config.noWait) {
|
26745
|
-
clauseSql.append(sql`
|
26746
|
+
clauseSql.append(sql` nowait`);
|
26746
26747
|
} else if (lockingClause.config.skipLocked) {
|
26747
26748
|
clauseSql.append(sql` skip locked`);
|
26748
26749
|
}
|
@@ -27718,12 +27719,12 @@ var init_select2 = __esm({
|
|
27718
27719
|
*
|
27719
27720
|
* ```ts
|
27720
27721
|
* // Select all users and their pets
|
27721
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
27722
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
27722
27723
|
* .from(users)
|
27723
27724
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
27724
27725
|
*
|
27725
27726
|
* // Select userId and petId
|
27726
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
27727
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
27727
27728
|
* userId: users.id,
|
27728
27729
|
* petId: pets.id,
|
27729
27730
|
* })
|
@@ -27731,7 +27732,20 @@ var init_select2 = __esm({
|
|
27731
27732
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
27732
27733
|
* ```
|
27733
27734
|
*/
|
27734
|
-
__publicField(this, "leftJoin", this.createJoin("left"));
|
27735
|
+
__publicField(this, "leftJoin", this.createJoin("left", false));
|
27736
|
+
/**
|
27737
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
27738
|
+
*
|
27739
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
27740
|
+
*
|
27741
|
+
* 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.
|
27742
|
+
*
|
27743
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
27744
|
+
*
|
27745
|
+
* @param table the subquery to join.
|
27746
|
+
* @param on the `on` clause.
|
27747
|
+
*/
|
27748
|
+
__publicField(this, "leftJoinLateral", this.createJoin("left", true));
|
27735
27749
|
/**
|
27736
27750
|
* Executes a `right join` operation by adding another table to the current query.
|
27737
27751
|
*
|
@@ -27746,12 +27760,12 @@ var init_select2 = __esm({
|
|
27746
27760
|
*
|
27747
27761
|
* ```ts
|
27748
27762
|
* // Select all users and their pets
|
27749
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
27763
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
27750
27764
|
* .from(users)
|
27751
27765
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
27752
27766
|
*
|
27753
27767
|
* // Select userId and petId
|
27754
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
27768
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
27755
27769
|
* userId: users.id,
|
27756
27770
|
* petId: pets.id,
|
27757
27771
|
* })
|
@@ -27759,7 +27773,7 @@ var init_select2 = __esm({
|
|
27759
27773
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
27760
27774
|
* ```
|
27761
27775
|
*/
|
27762
|
-
__publicField(this, "rightJoin", this.createJoin("right"));
|
27776
|
+
__publicField(this, "rightJoin", this.createJoin("right", false));
|
27763
27777
|
/**
|
27764
27778
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
27765
27779
|
*
|
@@ -27774,12 +27788,12 @@ var init_select2 = __esm({
|
|
27774
27788
|
*
|
27775
27789
|
* ```ts
|
27776
27790
|
* // Select all users and their pets
|
27777
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
27791
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
27778
27792
|
* .from(users)
|
27779
27793
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
27780
27794
|
*
|
27781
27795
|
* // Select userId and petId
|
27782
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
27796
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
27783
27797
|
* userId: users.id,
|
27784
27798
|
* petId: pets.id,
|
27785
27799
|
* })
|
@@ -27787,7 +27801,20 @@ var init_select2 = __esm({
|
|
27787
27801
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
27788
27802
|
* ```
|
27789
27803
|
*/
|
27790
|
-
__publicField(this, "innerJoin", this.createJoin("inner"));
|
27804
|
+
__publicField(this, "innerJoin", this.createJoin("inner", false));
|
27805
|
+
/**
|
27806
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
27807
|
+
*
|
27808
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
27809
|
+
*
|
27810
|
+
* 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.
|
27811
|
+
*
|
27812
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
27813
|
+
*
|
27814
|
+
* @param table the subquery to join.
|
27815
|
+
* @param on the `on` clause.
|
27816
|
+
*/
|
27817
|
+
__publicField(this, "innerJoinLateral", this.createJoin("inner", true));
|
27791
27818
|
/**
|
27792
27819
|
* Executes a `full join` operation by combining rows from two tables into a new table.
|
27793
27820
|
*
|
@@ -27802,12 +27829,12 @@ var init_select2 = __esm({
|
|
27802
27829
|
*
|
27803
27830
|
* ```ts
|
27804
27831
|
* // Select all users and their pets
|
27805
|
-
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
27832
|
+
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
27806
27833
|
* .from(users)
|
27807
27834
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
27808
27835
|
*
|
27809
27836
|
* // Select userId and petId
|
27810
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
27837
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
27811
27838
|
* userId: users.id,
|
27812
27839
|
* petId: pets.id,
|
27813
27840
|
* })
|
@@ -27815,7 +27842,46 @@ var init_select2 = __esm({
|
|
27815
27842
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
27816
27843
|
* ```
|
27817
27844
|
*/
|
27818
|
-
__publicField(this, "fullJoin", this.createJoin("full"));
|
27845
|
+
__publicField(this, "fullJoin", this.createJoin("full", false));
|
27846
|
+
/**
|
27847
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
27848
|
+
*
|
27849
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
27850
|
+
*
|
27851
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
27852
|
+
*
|
27853
|
+
* @param table the table to join.
|
27854
|
+
*
|
27855
|
+
* @example
|
27856
|
+
*
|
27857
|
+
* ```ts
|
27858
|
+
* // Select all users, each user with every pet
|
27859
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
27860
|
+
* .from(users)
|
27861
|
+
* .crossJoin(pets)
|
27862
|
+
*
|
27863
|
+
* // Select userId and petId
|
27864
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
27865
|
+
* userId: users.id,
|
27866
|
+
* petId: pets.id,
|
27867
|
+
* })
|
27868
|
+
* .from(users)
|
27869
|
+
* .crossJoin(pets)
|
27870
|
+
* ```
|
27871
|
+
*/
|
27872
|
+
__publicField(this, "crossJoin", this.createJoin("cross", false));
|
27873
|
+
/**
|
27874
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
27875
|
+
*
|
27876
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
27877
|
+
*
|
27878
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
27879
|
+
*
|
27880
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
27881
|
+
*
|
27882
|
+
* @param table the query to join.
|
27883
|
+
*/
|
27884
|
+
__publicField(this, "crossJoinLateral", this.createJoin("cross", true));
|
27819
27885
|
/**
|
27820
27886
|
* Adds `union` set operator to the query.
|
27821
27887
|
*
|
@@ -28018,7 +28084,7 @@ var init_select2 = __esm({
|
|
28018
28084
|
this.tableName = getTableLikeName(table6);
|
28019
28085
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
28020
28086
|
}
|
28021
|
-
createJoin(joinType) {
|
28087
|
+
createJoin(joinType, lateral) {
|
28022
28088
|
return (table6, on) => {
|
28023
28089
|
const baseTableName = this.tableName;
|
28024
28090
|
const tableName = getTableLikeName(table6);
|
@@ -28047,7 +28113,7 @@ var init_select2 = __esm({
|
|
28047
28113
|
if (!this.config.joins) {
|
28048
28114
|
this.config.joins = [];
|
28049
28115
|
}
|
28050
|
-
this.config.joins.push({ on, table: table6, joinType, alias: tableName });
|
28116
|
+
this.config.joins.push({ on, table: table6, joinType, alias: tableName, lateral });
|
28051
28117
|
if (typeof tableName === "string") {
|
28052
28118
|
switch (joinType) {
|
28053
28119
|
case "left": {
|
@@ -28061,6 +28127,7 @@ var init_select2 = __esm({
|
|
28061
28127
|
this.joinsNotNullableMap[tableName] = true;
|
28062
28128
|
break;
|
28063
28129
|
}
|
28130
|
+
case "cross":
|
28064
28131
|
case "inner": {
|
28065
28132
|
this.joinsNotNullableMap[tableName] = true;
|
28066
28133
|
break;
|
@@ -29976,18 +30043,18 @@ var init_schema = __esm({
|
|
29976
30043
|
__publicField(this, "materializedView", (name2, columns) => {
|
29977
30044
|
return pgMaterializedViewWithSchema(name2, columns, this.schemaName);
|
29978
30045
|
});
|
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
30046
|
__publicField(this, "sequence", (name2, options) => {
|
29987
30047
|
return pgSequenceWithSchema(name2, options, this.schemaName);
|
29988
30048
|
});
|
29989
30049
|
this.schemaName = schemaName;
|
29990
30050
|
}
|
30051
|
+
enum(enumName, input) {
|
30052
|
+
return Array.isArray(input) ? pgEnumWithSchema(
|
30053
|
+
enumName,
|
30054
|
+
[...input],
|
30055
|
+
this.schemaName
|
30056
|
+
) : pgEnumObjectWithSchema(enumName, input, this.schemaName);
|
30057
|
+
}
|
29991
30058
|
getSQL() {
|
29992
30059
|
return new SQL([sql.identifier(this.schemaName)]);
|
29993
30060
|
}
|
@@ -32978,17 +33045,18 @@ var init_dialect2 = __esm({
|
|
32978
33045
|
joinsArray.push(sql` `);
|
32979
33046
|
}
|
32980
33047
|
const table6 = joinMeta.table;
|
33048
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
32981
33049
|
if (is(table6, SQLiteTable)) {
|
32982
33050
|
const tableName = table6[SQLiteTable.Symbol.Name];
|
32983
33051
|
const tableSchema = table6[SQLiteTable.Symbol.Schema];
|
32984
33052
|
const origTableName = table6[SQLiteTable.Symbol.OriginalName];
|
32985
33053
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
32986
33054
|
joinsArray.push(
|
32987
|
-
sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}
|
33055
|
+
sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
32988
33056
|
);
|
32989
33057
|
} else {
|
32990
33058
|
joinsArray.push(
|
32991
|
-
sql`${sql.raw(joinMeta.joinType)} join ${table6}
|
33059
|
+
sql`${sql.raw(joinMeta.joinType)} join ${table6}${onSql}`
|
32992
33060
|
);
|
32993
33061
|
}
|
32994
33062
|
if (index6 < joins.length - 1) {
|
@@ -33562,12 +33630,12 @@ var init_select3 = __esm({
|
|
33562
33630
|
*
|
33563
33631
|
* ```ts
|
33564
33632
|
* // Select all users and their pets
|
33565
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
33633
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
33566
33634
|
* .from(users)
|
33567
33635
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
33568
33636
|
*
|
33569
33637
|
* // Select userId and petId
|
33570
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
33638
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
33571
33639
|
* userId: users.id,
|
33572
33640
|
* petId: pets.id,
|
33573
33641
|
* })
|
@@ -33590,12 +33658,12 @@ var init_select3 = __esm({
|
|
33590
33658
|
*
|
33591
33659
|
* ```ts
|
33592
33660
|
* // Select all users and their pets
|
33593
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
33661
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
33594
33662
|
* .from(users)
|
33595
33663
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
33596
33664
|
*
|
33597
33665
|
* // Select userId and petId
|
33598
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
33666
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
33599
33667
|
* userId: users.id,
|
33600
33668
|
* petId: pets.id,
|
33601
33669
|
* })
|
@@ -33618,12 +33686,12 @@ var init_select3 = __esm({
|
|
33618
33686
|
*
|
33619
33687
|
* ```ts
|
33620
33688
|
* // Select all users and their pets
|
33621
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
33689
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
33622
33690
|
* .from(users)
|
33623
33691
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
33624
33692
|
*
|
33625
33693
|
* // Select userId and petId
|
33626
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
33694
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
33627
33695
|
* userId: users.id,
|
33628
33696
|
* petId: pets.id,
|
33629
33697
|
* })
|
@@ -33646,12 +33714,12 @@ var init_select3 = __esm({
|
|
33646
33714
|
*
|
33647
33715
|
* ```ts
|
33648
33716
|
* // Select all users and their pets
|
33649
|
-
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
33717
|
+
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
33650
33718
|
* .from(users)
|
33651
33719
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
33652
33720
|
*
|
33653
33721
|
* // Select userId and petId
|
33654
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
33722
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
33655
33723
|
* userId: users.id,
|
33656
33724
|
* petId: pets.id,
|
33657
33725
|
* })
|
@@ -33660,6 +33728,33 @@ var init_select3 = __esm({
|
|
33660
33728
|
* ```
|
33661
33729
|
*/
|
33662
33730
|
__publicField(this, "fullJoin", this.createJoin("full"));
|
33731
|
+
/**
|
33732
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
33733
|
+
*
|
33734
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
33735
|
+
*
|
33736
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
33737
|
+
*
|
33738
|
+
* @param table the table to join.
|
33739
|
+
*
|
33740
|
+
* @example
|
33741
|
+
*
|
33742
|
+
* ```ts
|
33743
|
+
* // Select all users, each user with every pet
|
33744
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
33745
|
+
* .from(users)
|
33746
|
+
* .crossJoin(pets)
|
33747
|
+
*
|
33748
|
+
* // Select userId and petId
|
33749
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
33750
|
+
* userId: users.id,
|
33751
|
+
* petId: pets.id,
|
33752
|
+
* })
|
33753
|
+
* .from(users)
|
33754
|
+
* .crossJoin(pets)
|
33755
|
+
* ```
|
33756
|
+
*/
|
33757
|
+
__publicField(this, "crossJoin", this.createJoin("cross"));
|
33663
33758
|
/**
|
33664
33759
|
* Adds `union` set operator to the query.
|
33665
33760
|
*
|
@@ -33823,6 +33918,7 @@ var init_select3 = __esm({
|
|
33823
33918
|
this.joinsNotNullableMap[tableName] = true;
|
33824
33919
|
break;
|
33825
33920
|
}
|
33921
|
+
case "cross":
|
33826
33922
|
case "inner": {
|
33827
33923
|
this.joinsNotNullableMap[tableName] = true;
|
33828
33924
|
break;
|
@@ -38268,6 +38364,7 @@ var init_dialect3 = __esm({
|
|
38268
38364
|
}
|
38269
38365
|
const table22 = joinMeta.table;
|
38270
38366
|
const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
|
38367
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
38271
38368
|
if (is(table22, MySqlTable)) {
|
38272
38369
|
const tableName = table22[MySqlTable.Symbol.Name];
|
38273
38370
|
const tableSchema = table22[MySqlTable.Symbol.Schema];
|
@@ -38277,7 +38374,7 @@ var init_dialect3 = __esm({
|
|
38277
38374
|
const forceIndexSql2 = this.buildIndex({ indexes: joinMeta.forceIndex, indexFor: "FORCE" });
|
38278
38375
|
const ignoreIndexSql2 = this.buildIndex({ indexes: joinMeta.ignoreIndex, indexFor: "IGNORE" });
|
38279
38376
|
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)}`}
|
38377
|
+
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
38378
|
);
|
38282
38379
|
} else if (is(table22, View3)) {
|
38283
38380
|
const viewName = table22[ViewBaseConfig].name;
|
@@ -38285,11 +38382,11 @@ var init_dialect3 = __esm({
|
|
38285
38382
|
const origViewName = table22[ViewBaseConfig].originalName;
|
38286
38383
|
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
38287
38384
|
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)}`}
|
38385
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
38289
38386
|
);
|
38290
38387
|
} else {
|
38291
38388
|
joinsArray.push(
|
38292
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}
|
38389
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}${onSql}`
|
38293
38390
|
);
|
38294
38391
|
}
|
38295
38392
|
if (index6 < joins.length - 1) {
|
@@ -38312,7 +38409,7 @@ var init_dialect3 = __esm({
|
|
38312
38409
|
const { config, strength } = lockingClause;
|
38313
38410
|
lockingClausesSql = sql` for ${sql.raw(strength)}`;
|
38314
38411
|
if (config.noWait) {
|
38315
|
-
lockingClausesSql.append(sql`
|
38412
|
+
lockingClausesSql.append(sql` nowait`);
|
38316
38413
|
} else if (config.skipLocked) {
|
38317
38414
|
lockingClausesSql.append(sql` skip locked`);
|
38318
38415
|
}
|
@@ -39179,17 +39276,18 @@ var init_select4 = __esm({
|
|
39179
39276
|
*
|
39180
39277
|
* @param table the table to join.
|
39181
39278
|
* @param on the `on` clause.
|
39279
|
+
* @param onIndex index hint.
|
39182
39280
|
*
|
39183
39281
|
* @example
|
39184
39282
|
*
|
39185
39283
|
* ```ts
|
39186
39284
|
* // Select all users and their pets
|
39187
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
39285
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
39188
39286
|
* .from(users)
|
39189
39287
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
39190
39288
|
*
|
39191
39289
|
* // Select userId and petId
|
39192
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
39290
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
39193
39291
|
* userId: users.id,
|
39194
39292
|
* petId: pets.id,
|
39195
39293
|
* })
|
@@ -39197,7 +39295,7 @@ var init_select4 = __esm({
|
|
39197
39295
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
39198
39296
|
*
|
39199
39297
|
* // Select userId and petId with use index hint
|
39200
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
39298
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
39201
39299
|
* userId: users.id,
|
39202
39300
|
* petId: pets.id,
|
39203
39301
|
* })
|
@@ -39207,7 +39305,20 @@ var init_select4 = __esm({
|
|
39207
39305
|
* })
|
39208
39306
|
* ```
|
39209
39307
|
*/
|
39210
|
-
__publicField(this, "leftJoin", this.createJoin("left"));
|
39308
|
+
__publicField(this, "leftJoin", this.createJoin("left", false));
|
39309
|
+
/**
|
39310
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
39311
|
+
*
|
39312
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
39313
|
+
*
|
39314
|
+
* 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.
|
39315
|
+
*
|
39316
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
39317
|
+
*
|
39318
|
+
* @param table the subquery to join.
|
39319
|
+
* @param on the `on` clause.
|
39320
|
+
*/
|
39321
|
+
__publicField(this, "leftJoinLateral", this.createJoin("left", true));
|
39211
39322
|
/**
|
39212
39323
|
* Executes a `right join` operation by adding another table to the current query.
|
39213
39324
|
*
|
@@ -39217,17 +39328,18 @@ var init_select4 = __esm({
|
|
39217
39328
|
*
|
39218
39329
|
* @param table the table to join.
|
39219
39330
|
* @param on the `on` clause.
|
39331
|
+
* @param onIndex index hint.
|
39220
39332
|
*
|
39221
39333
|
* @example
|
39222
39334
|
*
|
39223
39335
|
* ```ts
|
39224
39336
|
* // Select all users and their pets
|
39225
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
39337
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
39226
39338
|
* .from(users)
|
39227
39339
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
39228
39340
|
*
|
39229
39341
|
* // Select userId and petId
|
39230
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
39342
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
39231
39343
|
* userId: users.id,
|
39232
39344
|
* petId: pets.id,
|
39233
39345
|
* })
|
@@ -39235,7 +39347,7 @@ var init_select4 = __esm({
|
|
39235
39347
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
39236
39348
|
*
|
39237
39349
|
* // Select userId and petId with use index hint
|
39238
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
39350
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
39239
39351
|
* userId: users.id,
|
39240
39352
|
* petId: pets.id,
|
39241
39353
|
* })
|
@@ -39245,7 +39357,7 @@ var init_select4 = __esm({
|
|
39245
39357
|
* })
|
39246
39358
|
* ```
|
39247
39359
|
*/
|
39248
|
-
__publicField(this, "rightJoin", this.createJoin("right"));
|
39360
|
+
__publicField(this, "rightJoin", this.createJoin("right", false));
|
39249
39361
|
/**
|
39250
39362
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
39251
39363
|
*
|
@@ -39255,17 +39367,18 @@ var init_select4 = __esm({
|
|
39255
39367
|
*
|
39256
39368
|
* @param table the table to join.
|
39257
39369
|
* @param on the `on` clause.
|
39370
|
+
* @param onIndex index hint.
|
39258
39371
|
*
|
39259
39372
|
* @example
|
39260
39373
|
*
|
39261
39374
|
* ```ts
|
39262
39375
|
* // Select all users and their pets
|
39263
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
39376
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
39264
39377
|
* .from(users)
|
39265
39378
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
39266
39379
|
*
|
39267
39380
|
* // Select userId and petId
|
39268
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
39381
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
39269
39382
|
* userId: users.id,
|
39270
39383
|
* petId: pets.id,
|
39271
39384
|
* })
|
@@ -39273,7 +39386,7 @@ var init_select4 = __esm({
|
|
39273
39386
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
39274
39387
|
*
|
39275
39388
|
* // Select userId and petId with use index hint
|
39276
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
39389
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
39277
39390
|
* userId: users.id,
|
39278
39391
|
* petId: pets.id,
|
39279
39392
|
* })
|
@@ -39283,45 +39396,70 @@ var init_select4 = __esm({
|
|
39283
39396
|
* })
|
39284
39397
|
* ```
|
39285
39398
|
*/
|
39286
|
-
__publicField(this, "innerJoin", this.createJoin("inner"));
|
39399
|
+
__publicField(this, "innerJoin", this.createJoin("inner", false));
|
39287
39400
|
/**
|
39288
|
-
* Executes
|
39401
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
39289
39402
|
*
|
39290
|
-
*
|
39403
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
39291
39404
|
*
|
39292
|
-
*
|
39405
|
+
* 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
39406
|
*
|
39294
|
-
*
|
39407
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
39408
|
+
*
|
39409
|
+
* @param table the subquery to join.
|
39295
39410
|
* @param on the `on` clause.
|
39411
|
+
*/
|
39412
|
+
__publicField(this, "innerJoinLateral", this.createJoin("inner", true));
|
39413
|
+
/**
|
39414
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
39415
|
+
*
|
39416
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
39417
|
+
*
|
39418
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
39419
|
+
*
|
39420
|
+
* @param table the table to join.
|
39421
|
+
* @param onIndex index hint.
|
39296
39422
|
*
|
39297
39423
|
* @example
|
39298
39424
|
*
|
39299
39425
|
* ```ts
|
39300
|
-
* // Select all users
|
39301
|
-
* const usersWithPets: { user: User
|
39426
|
+
* // Select all users, each user with every pet
|
39427
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
39302
39428
|
* .from(users)
|
39303
|
-
* .
|
39429
|
+
* .crossJoin(pets)
|
39304
39430
|
*
|
39305
39431
|
* // Select userId and petId
|
39306
|
-
* const usersIdsAndPetIds: { userId: number
|
39432
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
39307
39433
|
* userId: users.id,
|
39308
39434
|
* petId: pets.id,
|
39309
39435
|
* })
|
39310
39436
|
* .from(users)
|
39311
|
-
* .
|
39437
|
+
* .crossJoin(pets)
|
39312
39438
|
*
|
39313
39439
|
* // Select userId and petId with use index hint
|
39314
|
-
* const usersIdsAndPetIds: { userId: number; petId: number
|
39440
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
39315
39441
|
* userId: users.id,
|
39316
39442
|
* petId: pets.id,
|
39317
39443
|
* })
|
39318
39444
|
* .from(users)
|
39319
|
-
* .
|
39445
|
+
* .crossJoin(pets, {
|
39320
39446
|
* useIndex: ['pets_owner_id_index']
|
39321
39447
|
* })
|
39322
39448
|
* ```
|
39323
39449
|
*/
|
39324
|
-
__publicField(this, "
|
39450
|
+
__publicField(this, "crossJoin", this.createJoin("cross", false));
|
39451
|
+
/**
|
39452
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
39453
|
+
*
|
39454
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
39455
|
+
*
|
39456
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
39457
|
+
*
|
39458
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
39459
|
+
*
|
39460
|
+
* @param table the query to join.
|
39461
|
+
*/
|
39462
|
+
__publicField(this, "crossJoinLateral", this.createJoin("cross", true));
|
39325
39463
|
/**
|
39326
39464
|
* Adds `union` set operator to the query.
|
39327
39465
|
*
|
@@ -39527,8 +39665,11 @@ var init_select4 = __esm({
|
|
39527
39665
|
this.tableName = getTableLikeName(table6);
|
39528
39666
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
39529
39667
|
}
|
39530
|
-
createJoin(joinType) {
|
39531
|
-
return (table6,
|
39668
|
+
createJoin(joinType, lateral) {
|
39669
|
+
return (table6, a, b) => {
|
39670
|
+
const isCrossJoin = joinType === "cross";
|
39671
|
+
let on = isCrossJoin ? void 0 : a;
|
39672
|
+
const onIndex = isCrossJoin ? a : b;
|
39532
39673
|
const baseTableName = this.tableName;
|
39533
39674
|
const tableName = getTableLikeName(table6);
|
39534
39675
|
if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
|
@@ -39570,7 +39711,7 @@ var init_select4 = __esm({
|
|
39570
39711
|
ignoreIndex = convertIndexToString(toArray(onIndex.ignoreIndex));
|
39571
39712
|
}
|
39572
39713
|
}
|
39573
|
-
this.config.joins.push({ on, table: table6, joinType, alias: tableName, useIndex, forceIndex, ignoreIndex });
|
39714
|
+
this.config.joins.push({ on, table: table6, joinType, alias: tableName, useIndex, forceIndex, ignoreIndex, lateral });
|
39574
39715
|
if (typeof tableName === "string") {
|
39575
39716
|
switch (joinType) {
|
39576
39717
|
case "left": {
|
@@ -39584,17 +39725,11 @@ var init_select4 = __esm({
|
|
39584
39725
|
this.joinsNotNullableMap[tableName] = true;
|
39585
39726
|
break;
|
39586
39727
|
}
|
39728
|
+
case "cross":
|
39587
39729
|
case "inner": {
|
39588
39730
|
this.joinsNotNullableMap[tableName] = true;
|
39589
39731
|
break;
|
39590
39732
|
}
|
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
39733
|
}
|
39599
39734
|
}
|
39600
39735
|
return this;
|
@@ -44088,13 +44223,14 @@ var init_dialect4 = __esm({
|
|
44088
44223
|
}
|
44089
44224
|
const table22 = joinMeta.table;
|
44090
44225
|
const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
|
44226
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
44091
44227
|
if (is(table22, SingleStoreTable)) {
|
44092
44228
|
const tableName = table22[SingleStoreTable.Symbol.Name];
|
44093
44229
|
const tableSchema = table22[SingleStoreTable.Symbol.Schema];
|
44094
44230
|
const origTableName = table22[SingleStoreTable.Symbol.OriginalName];
|
44095
44231
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
44096
44232
|
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)}`}
|
44233
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
44098
44234
|
);
|
44099
44235
|
} else if (is(table22, View3)) {
|
44100
44236
|
const viewName = table22[ViewBaseConfig].name;
|
@@ -44102,11 +44238,11 @@ var init_dialect4 = __esm({
|
|
44102
44238
|
const origViewName = table22[ViewBaseConfig].originalName;
|
44103
44239
|
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
44104
44240
|
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)}`}
|
44241
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
44106
44242
|
);
|
44107
44243
|
} else {
|
44108
44244
|
joinsArray.push(
|
44109
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}
|
44245
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}${onSql}`
|
44110
44246
|
);
|
44111
44247
|
}
|
44112
44248
|
if (index6 < joins.length - 1) {
|
@@ -44126,7 +44262,7 @@ var init_dialect4 = __esm({
|
|
44126
44262
|
const { config, strength } = lockingClause;
|
44127
44263
|
lockingClausesSql = sql` for ${sql.raw(strength)}`;
|
44128
44264
|
if (config.noWait) {
|
44129
|
-
lockingClausesSql.append(sql`
|
44265
|
+
lockingClausesSql.append(sql` nowait`);
|
44130
44266
|
} else if (config.skipLocked) {
|
44131
44267
|
lockingClausesSql.append(sql` skip locked`);
|
44132
44268
|
}
|
@@ -44566,12 +44702,12 @@ var init_select5 = __esm({
|
|
44566
44702
|
*
|
44567
44703
|
* ```ts
|
44568
44704
|
* // Select all users and their pets
|
44569
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
44705
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
44570
44706
|
* .from(users)
|
44571
44707
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
44572
44708
|
*
|
44573
44709
|
* // Select userId and petId
|
44574
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
44710
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
44575
44711
|
* userId: users.id,
|
44576
44712
|
* petId: pets.id,
|
44577
44713
|
* })
|
@@ -44579,7 +44715,20 @@ var init_select5 = __esm({
|
|
44579
44715
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
44580
44716
|
* ```
|
44581
44717
|
*/
|
44582
|
-
__publicField(this, "leftJoin", this.createJoin("left"));
|
44718
|
+
__publicField(this, "leftJoin", this.createJoin("left", false));
|
44719
|
+
/**
|
44720
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
44721
|
+
*
|
44722
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
44723
|
+
*
|
44724
|
+
* 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.
|
44725
|
+
*
|
44726
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
44727
|
+
*
|
44728
|
+
* @param table the subquery to join.
|
44729
|
+
* @param on the `on` clause.
|
44730
|
+
*/
|
44731
|
+
__publicField(this, "leftJoinLateral", this.createJoin("left", true));
|
44583
44732
|
/**
|
44584
44733
|
* Executes a `right join` operation by adding another table to the current query.
|
44585
44734
|
*
|
@@ -44594,12 +44743,12 @@ var init_select5 = __esm({
|
|
44594
44743
|
*
|
44595
44744
|
* ```ts
|
44596
44745
|
* // Select all users and their pets
|
44597
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
44746
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
44598
44747
|
* .from(users)
|
44599
44748
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
44600
44749
|
*
|
44601
44750
|
* // Select userId and petId
|
44602
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
44751
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
44603
44752
|
* userId: users.id,
|
44604
44753
|
* petId: pets.id,
|
44605
44754
|
* })
|
@@ -44607,7 +44756,7 @@ var init_select5 = __esm({
|
|
44607
44756
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
44608
44757
|
* ```
|
44609
44758
|
*/
|
44610
|
-
__publicField(this, "rightJoin", this.createJoin("right"));
|
44759
|
+
__publicField(this, "rightJoin", this.createJoin("right", false));
|
44611
44760
|
/**
|
44612
44761
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
44613
44762
|
*
|
@@ -44622,12 +44771,12 @@ var init_select5 = __esm({
|
|
44622
44771
|
*
|
44623
44772
|
* ```ts
|
44624
44773
|
* // Select all users and their pets
|
44625
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
44774
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
44626
44775
|
* .from(users)
|
44627
44776
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
44628
44777
|
*
|
44629
44778
|
* // Select userId and petId
|
44630
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
44779
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
44631
44780
|
* userId: users.id,
|
44632
44781
|
* petId: pets.id,
|
44633
44782
|
* })
|
@@ -44635,7 +44784,20 @@ var init_select5 = __esm({
|
|
44635
44784
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
44636
44785
|
* ```
|
44637
44786
|
*/
|
44638
|
-
__publicField(this, "innerJoin", this.createJoin("inner"));
|
44787
|
+
__publicField(this, "innerJoin", this.createJoin("inner", false));
|
44788
|
+
/**
|
44789
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
44790
|
+
*
|
44791
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
44792
|
+
*
|
44793
|
+
* 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.
|
44794
|
+
*
|
44795
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
44796
|
+
*
|
44797
|
+
* @param table the subquery to join.
|
44798
|
+
* @param on the `on` clause.
|
44799
|
+
*/
|
44800
|
+
__publicField(this, "innerJoinLateral", this.createJoin("inner", true));
|
44639
44801
|
/**
|
44640
44802
|
* Executes a `full join` operation by combining rows from two tables into a new table.
|
44641
44803
|
*
|
@@ -44650,12 +44812,12 @@ var init_select5 = __esm({
|
|
44650
44812
|
*
|
44651
44813
|
* ```ts
|
44652
44814
|
* // Select all users and their pets
|
44653
|
-
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
44815
|
+
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
44654
44816
|
* .from(users)
|
44655
44817
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
44656
44818
|
*
|
44657
44819
|
* // Select userId and petId
|
44658
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
44820
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
44659
44821
|
* userId: users.id,
|
44660
44822
|
* petId: pets.id,
|
44661
44823
|
* })
|
@@ -44663,7 +44825,46 @@ var init_select5 = __esm({
|
|
44663
44825
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
44664
44826
|
* ```
|
44665
44827
|
*/
|
44666
|
-
__publicField(this, "fullJoin", this.createJoin("full"));
|
44828
|
+
__publicField(this, "fullJoin", this.createJoin("full", false));
|
44829
|
+
/**
|
44830
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
44831
|
+
*
|
44832
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
44833
|
+
*
|
44834
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
44835
|
+
*
|
44836
|
+
* @param table the table to join.
|
44837
|
+
*
|
44838
|
+
* @example
|
44839
|
+
*
|
44840
|
+
* ```ts
|
44841
|
+
* // Select all users, each user with every pet
|
44842
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
44843
|
+
* .from(users)
|
44844
|
+
* .crossJoin(pets)
|
44845
|
+
*
|
44846
|
+
* // Select userId and petId
|
44847
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
44848
|
+
* userId: users.id,
|
44849
|
+
* petId: pets.id,
|
44850
|
+
* })
|
44851
|
+
* .from(users)
|
44852
|
+
* .crossJoin(pets)
|
44853
|
+
* ```
|
44854
|
+
*/
|
44855
|
+
__publicField(this, "crossJoin", this.createJoin("cross", false));
|
44856
|
+
/**
|
44857
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
44858
|
+
*
|
44859
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
44860
|
+
*
|
44861
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
44862
|
+
*
|
44863
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
44864
|
+
*
|
44865
|
+
* @param table the query to join.
|
44866
|
+
*/
|
44867
|
+
__publicField(this, "crossJoinLateral", this.createJoin("cross", true));
|
44667
44868
|
/**
|
44668
44869
|
* Adds `union` set operator to the query.
|
44669
44870
|
*
|
@@ -44808,7 +45009,7 @@ var init_select5 = __esm({
|
|
44808
45009
|
this.tableName = getTableLikeName(table6);
|
44809
45010
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
44810
45011
|
}
|
44811
|
-
createJoin(joinType) {
|
45012
|
+
createJoin(joinType, lateral) {
|
44812
45013
|
return (table6, on) => {
|
44813
45014
|
const baseTableName = this.tableName;
|
44814
45015
|
const tableName = getTableLikeName(table6);
|
@@ -44837,7 +45038,7 @@ var init_select5 = __esm({
|
|
44837
45038
|
if (!this.config.joins) {
|
44838
45039
|
this.config.joins = [];
|
44839
45040
|
}
|
44840
|
-
this.config.joins.push({ on, table: table6, joinType, alias: tableName });
|
45041
|
+
this.config.joins.push({ on, table: table6, joinType, alias: tableName, lateral });
|
44841
45042
|
if (typeof tableName === "string") {
|
44842
45043
|
switch (joinType) {
|
44843
45044
|
case "left": {
|
@@ -44851,6 +45052,7 @@ var init_select5 = __esm({
|
|
44851
45052
|
this.joinsNotNullableMap[tableName] = true;
|
44852
45053
|
break;
|
44853
45054
|
}
|
45055
|
+
case "cross":
|
44854
45056
|
case "inner": {
|
44855
45057
|
this.joinsNotNullableMap[tableName] = true;
|
44856
45058
|
break;
|