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.mjs
CHANGED
@@ -22667,7 +22667,7 @@ var version;
|
|
22667
22667
|
var init_version = __esm({
|
22668
22668
|
"../drizzle-orm/dist/version.js"() {
|
22669
22669
|
"use strict";
|
22670
|
-
version = "0.
|
22670
|
+
version = "0.43.1";
|
22671
22671
|
}
|
22672
22672
|
});
|
22673
22673
|
|
@@ -26650,13 +26650,14 @@ var init_dialect = __esm({
|
|
26650
26650
|
}
|
26651
26651
|
const table6 = joinMeta.table;
|
26652
26652
|
const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
|
26653
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
26653
26654
|
if (is(table6, PgTable)) {
|
26654
26655
|
const tableName = table6[PgTable.Symbol.Name];
|
26655
26656
|
const tableSchema = table6[PgTable.Symbol.Schema];
|
26656
26657
|
const origTableName = table6[PgTable.Symbol.OriginalName];
|
26657
26658
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
26658
26659
|
joinsArray.push(
|
26659
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}
|
26660
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
26660
26661
|
);
|
26661
26662
|
} else if (is(table6, View3)) {
|
26662
26663
|
const viewName = table6[ViewBaseConfig].name;
|
@@ -26664,11 +26665,11 @@ var init_dialect = __esm({
|
|
26664
26665
|
const origViewName = table6[ViewBaseConfig].originalName;
|
26665
26666
|
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
26666
26667
|
joinsArray.push(
|
26667
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}
|
26668
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
26668
26669
|
);
|
26669
26670
|
} else {
|
26670
26671
|
joinsArray.push(
|
26671
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table6}
|
26672
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table6}${onSql}`
|
26672
26673
|
);
|
26673
26674
|
}
|
26674
26675
|
if (index6 < joins.length - 1) {
|
@@ -26747,7 +26748,7 @@ var init_dialect = __esm({
|
|
26747
26748
|
);
|
26748
26749
|
}
|
26749
26750
|
if (lockingClause.config.noWait) {
|
26750
|
-
clauseSql.append(sql`
|
26751
|
+
clauseSql.append(sql` nowait`);
|
26751
26752
|
} else if (lockingClause.config.skipLocked) {
|
26752
26753
|
clauseSql.append(sql` skip locked`);
|
26753
26754
|
}
|
@@ -27723,12 +27724,12 @@ var init_select2 = __esm({
|
|
27723
27724
|
*
|
27724
27725
|
* ```ts
|
27725
27726
|
* // Select all users and their pets
|
27726
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
27727
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
27727
27728
|
* .from(users)
|
27728
27729
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
27729
27730
|
*
|
27730
27731
|
* // Select userId and petId
|
27731
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
27732
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
27732
27733
|
* userId: users.id,
|
27733
27734
|
* petId: pets.id,
|
27734
27735
|
* })
|
@@ -27736,7 +27737,20 @@ var init_select2 = __esm({
|
|
27736
27737
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
27737
27738
|
* ```
|
27738
27739
|
*/
|
27739
|
-
__publicField(this, "leftJoin", this.createJoin("left"));
|
27740
|
+
__publicField(this, "leftJoin", this.createJoin("left", false));
|
27741
|
+
/**
|
27742
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
27743
|
+
*
|
27744
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
27745
|
+
*
|
27746
|
+
* 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.
|
27747
|
+
*
|
27748
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
27749
|
+
*
|
27750
|
+
* @param table the subquery to join.
|
27751
|
+
* @param on the `on` clause.
|
27752
|
+
*/
|
27753
|
+
__publicField(this, "leftJoinLateral", this.createJoin("left", true));
|
27740
27754
|
/**
|
27741
27755
|
* Executes a `right join` operation by adding another table to the current query.
|
27742
27756
|
*
|
@@ -27751,12 +27765,12 @@ var init_select2 = __esm({
|
|
27751
27765
|
*
|
27752
27766
|
* ```ts
|
27753
27767
|
* // Select all users and their pets
|
27754
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
27768
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
27755
27769
|
* .from(users)
|
27756
27770
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
27757
27771
|
*
|
27758
27772
|
* // Select userId and petId
|
27759
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
27773
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
27760
27774
|
* userId: users.id,
|
27761
27775
|
* petId: pets.id,
|
27762
27776
|
* })
|
@@ -27764,7 +27778,7 @@ var init_select2 = __esm({
|
|
27764
27778
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
27765
27779
|
* ```
|
27766
27780
|
*/
|
27767
|
-
__publicField(this, "rightJoin", this.createJoin("right"));
|
27781
|
+
__publicField(this, "rightJoin", this.createJoin("right", false));
|
27768
27782
|
/**
|
27769
27783
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
27770
27784
|
*
|
@@ -27779,12 +27793,12 @@ var init_select2 = __esm({
|
|
27779
27793
|
*
|
27780
27794
|
* ```ts
|
27781
27795
|
* // Select all users and their pets
|
27782
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
27796
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
27783
27797
|
* .from(users)
|
27784
27798
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
27785
27799
|
*
|
27786
27800
|
* // Select userId and petId
|
27787
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
27801
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
27788
27802
|
* userId: users.id,
|
27789
27803
|
* petId: pets.id,
|
27790
27804
|
* })
|
@@ -27792,7 +27806,20 @@ var init_select2 = __esm({
|
|
27792
27806
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
27793
27807
|
* ```
|
27794
27808
|
*/
|
27795
|
-
__publicField(this, "innerJoin", this.createJoin("inner"));
|
27809
|
+
__publicField(this, "innerJoin", this.createJoin("inner", false));
|
27810
|
+
/**
|
27811
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
27812
|
+
*
|
27813
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
27814
|
+
*
|
27815
|
+
* 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.
|
27816
|
+
*
|
27817
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
27818
|
+
*
|
27819
|
+
* @param table the subquery to join.
|
27820
|
+
* @param on the `on` clause.
|
27821
|
+
*/
|
27822
|
+
__publicField(this, "innerJoinLateral", this.createJoin("inner", true));
|
27796
27823
|
/**
|
27797
27824
|
* Executes a `full join` operation by combining rows from two tables into a new table.
|
27798
27825
|
*
|
@@ -27807,12 +27834,12 @@ var init_select2 = __esm({
|
|
27807
27834
|
*
|
27808
27835
|
* ```ts
|
27809
27836
|
* // Select all users and their pets
|
27810
|
-
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
27837
|
+
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
27811
27838
|
* .from(users)
|
27812
27839
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
27813
27840
|
*
|
27814
27841
|
* // Select userId and petId
|
27815
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
27842
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
27816
27843
|
* userId: users.id,
|
27817
27844
|
* petId: pets.id,
|
27818
27845
|
* })
|
@@ -27820,7 +27847,46 @@ var init_select2 = __esm({
|
|
27820
27847
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
27821
27848
|
* ```
|
27822
27849
|
*/
|
27823
|
-
__publicField(this, "fullJoin", this.createJoin("full"));
|
27850
|
+
__publicField(this, "fullJoin", this.createJoin("full", false));
|
27851
|
+
/**
|
27852
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
27853
|
+
*
|
27854
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
27855
|
+
*
|
27856
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
27857
|
+
*
|
27858
|
+
* @param table the table to join.
|
27859
|
+
*
|
27860
|
+
* @example
|
27861
|
+
*
|
27862
|
+
* ```ts
|
27863
|
+
* // Select all users, each user with every pet
|
27864
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
27865
|
+
* .from(users)
|
27866
|
+
* .crossJoin(pets)
|
27867
|
+
*
|
27868
|
+
* // Select userId and petId
|
27869
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
27870
|
+
* userId: users.id,
|
27871
|
+
* petId: pets.id,
|
27872
|
+
* })
|
27873
|
+
* .from(users)
|
27874
|
+
* .crossJoin(pets)
|
27875
|
+
* ```
|
27876
|
+
*/
|
27877
|
+
__publicField(this, "crossJoin", this.createJoin("cross", false));
|
27878
|
+
/**
|
27879
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
27880
|
+
*
|
27881
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
27882
|
+
*
|
27883
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
27884
|
+
*
|
27885
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
27886
|
+
*
|
27887
|
+
* @param table the query to join.
|
27888
|
+
*/
|
27889
|
+
__publicField(this, "crossJoinLateral", this.createJoin("cross", true));
|
27824
27890
|
/**
|
27825
27891
|
* Adds `union` set operator to the query.
|
27826
27892
|
*
|
@@ -28023,7 +28089,7 @@ var init_select2 = __esm({
|
|
28023
28089
|
this.tableName = getTableLikeName(table6);
|
28024
28090
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
28025
28091
|
}
|
28026
|
-
createJoin(joinType) {
|
28092
|
+
createJoin(joinType, lateral) {
|
28027
28093
|
return (table6, on) => {
|
28028
28094
|
const baseTableName = this.tableName;
|
28029
28095
|
const tableName = getTableLikeName(table6);
|
@@ -28052,7 +28118,7 @@ var init_select2 = __esm({
|
|
28052
28118
|
if (!this.config.joins) {
|
28053
28119
|
this.config.joins = [];
|
28054
28120
|
}
|
28055
|
-
this.config.joins.push({ on, table: table6, joinType, alias: tableName });
|
28121
|
+
this.config.joins.push({ on, table: table6, joinType, alias: tableName, lateral });
|
28056
28122
|
if (typeof tableName === "string") {
|
28057
28123
|
switch (joinType) {
|
28058
28124
|
case "left": {
|
@@ -28066,6 +28132,7 @@ var init_select2 = __esm({
|
|
28066
28132
|
this.joinsNotNullableMap[tableName] = true;
|
28067
28133
|
break;
|
28068
28134
|
}
|
28135
|
+
case "cross":
|
28069
28136
|
case "inner": {
|
28070
28137
|
this.joinsNotNullableMap[tableName] = true;
|
28071
28138
|
break;
|
@@ -29981,18 +30048,18 @@ var init_schema = __esm({
|
|
29981
30048
|
__publicField(this, "materializedView", (name2, columns) => {
|
29982
30049
|
return pgMaterializedViewWithSchema(name2, columns, this.schemaName);
|
29983
30050
|
});
|
29984
|
-
__publicField(this, "enum", (enumName, input) => {
|
29985
|
-
return Array.isArray(input) ? pgEnumWithSchema(
|
29986
|
-
enumName,
|
29987
|
-
[...input],
|
29988
|
-
this.schemaName
|
29989
|
-
) : pgEnumObjectWithSchema(enumName, input, this.schemaName);
|
29990
|
-
});
|
29991
30051
|
__publicField(this, "sequence", (name2, options) => {
|
29992
30052
|
return pgSequenceWithSchema(name2, options, this.schemaName);
|
29993
30053
|
});
|
29994
30054
|
this.schemaName = schemaName;
|
29995
30055
|
}
|
30056
|
+
enum(enumName, input) {
|
30057
|
+
return Array.isArray(input) ? pgEnumWithSchema(
|
30058
|
+
enumName,
|
30059
|
+
[...input],
|
30060
|
+
this.schemaName
|
30061
|
+
) : pgEnumObjectWithSchema(enumName, input, this.schemaName);
|
30062
|
+
}
|
29996
30063
|
getSQL() {
|
29997
30064
|
return new SQL([sql.identifier(this.schemaName)]);
|
29998
30065
|
}
|
@@ -32983,17 +33050,18 @@ var init_dialect2 = __esm({
|
|
32983
33050
|
joinsArray.push(sql` `);
|
32984
33051
|
}
|
32985
33052
|
const table6 = joinMeta.table;
|
33053
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
32986
33054
|
if (is(table6, SQLiteTable)) {
|
32987
33055
|
const tableName = table6[SQLiteTable.Symbol.Name];
|
32988
33056
|
const tableSchema = table6[SQLiteTable.Symbol.Schema];
|
32989
33057
|
const origTableName = table6[SQLiteTable.Symbol.OriginalName];
|
32990
33058
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
32991
33059
|
joinsArray.push(
|
32992
|
-
sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}
|
33060
|
+
sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
32993
33061
|
);
|
32994
33062
|
} else {
|
32995
33063
|
joinsArray.push(
|
32996
|
-
sql`${sql.raw(joinMeta.joinType)} join ${table6}
|
33064
|
+
sql`${sql.raw(joinMeta.joinType)} join ${table6}${onSql}`
|
32997
33065
|
);
|
32998
33066
|
}
|
32999
33067
|
if (index6 < joins.length - 1) {
|
@@ -33567,12 +33635,12 @@ var init_select3 = __esm({
|
|
33567
33635
|
*
|
33568
33636
|
* ```ts
|
33569
33637
|
* // Select all users and their pets
|
33570
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
33638
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
33571
33639
|
* .from(users)
|
33572
33640
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
33573
33641
|
*
|
33574
33642
|
* // Select userId and petId
|
33575
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
33643
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
33576
33644
|
* userId: users.id,
|
33577
33645
|
* petId: pets.id,
|
33578
33646
|
* })
|
@@ -33595,12 +33663,12 @@ var init_select3 = __esm({
|
|
33595
33663
|
*
|
33596
33664
|
* ```ts
|
33597
33665
|
* // Select all users and their pets
|
33598
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
33666
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
33599
33667
|
* .from(users)
|
33600
33668
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
33601
33669
|
*
|
33602
33670
|
* // Select userId and petId
|
33603
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
33671
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
33604
33672
|
* userId: users.id,
|
33605
33673
|
* petId: pets.id,
|
33606
33674
|
* })
|
@@ -33623,12 +33691,12 @@ var init_select3 = __esm({
|
|
33623
33691
|
*
|
33624
33692
|
* ```ts
|
33625
33693
|
* // Select all users and their pets
|
33626
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
33694
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
33627
33695
|
* .from(users)
|
33628
33696
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
33629
33697
|
*
|
33630
33698
|
* // Select userId and petId
|
33631
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
33699
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
33632
33700
|
* userId: users.id,
|
33633
33701
|
* petId: pets.id,
|
33634
33702
|
* })
|
@@ -33651,12 +33719,12 @@ var init_select3 = __esm({
|
|
33651
33719
|
*
|
33652
33720
|
* ```ts
|
33653
33721
|
* // Select all users and their pets
|
33654
|
-
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
33722
|
+
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
33655
33723
|
* .from(users)
|
33656
33724
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
33657
33725
|
*
|
33658
33726
|
* // Select userId and petId
|
33659
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
33727
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
33660
33728
|
* userId: users.id,
|
33661
33729
|
* petId: pets.id,
|
33662
33730
|
* })
|
@@ -33665,6 +33733,33 @@ var init_select3 = __esm({
|
|
33665
33733
|
* ```
|
33666
33734
|
*/
|
33667
33735
|
__publicField(this, "fullJoin", this.createJoin("full"));
|
33736
|
+
/**
|
33737
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
33738
|
+
*
|
33739
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
33740
|
+
*
|
33741
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
33742
|
+
*
|
33743
|
+
* @param table the table to join.
|
33744
|
+
*
|
33745
|
+
* @example
|
33746
|
+
*
|
33747
|
+
* ```ts
|
33748
|
+
* // Select all users, each user with every pet
|
33749
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
33750
|
+
* .from(users)
|
33751
|
+
* .crossJoin(pets)
|
33752
|
+
*
|
33753
|
+
* // Select userId and petId
|
33754
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
33755
|
+
* userId: users.id,
|
33756
|
+
* petId: pets.id,
|
33757
|
+
* })
|
33758
|
+
* .from(users)
|
33759
|
+
* .crossJoin(pets)
|
33760
|
+
* ```
|
33761
|
+
*/
|
33762
|
+
__publicField(this, "crossJoin", this.createJoin("cross"));
|
33668
33763
|
/**
|
33669
33764
|
* Adds `union` set operator to the query.
|
33670
33765
|
*
|
@@ -33828,6 +33923,7 @@ var init_select3 = __esm({
|
|
33828
33923
|
this.joinsNotNullableMap[tableName] = true;
|
33829
33924
|
break;
|
33830
33925
|
}
|
33926
|
+
case "cross":
|
33831
33927
|
case "inner": {
|
33832
33928
|
this.joinsNotNullableMap[tableName] = true;
|
33833
33929
|
break;
|
@@ -38273,6 +38369,7 @@ var init_dialect3 = __esm({
|
|
38273
38369
|
}
|
38274
38370
|
const table22 = joinMeta.table;
|
38275
38371
|
const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
|
38372
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
38276
38373
|
if (is(table22, MySqlTable)) {
|
38277
38374
|
const tableName = table22[MySqlTable.Symbol.Name];
|
38278
38375
|
const tableSchema = table22[MySqlTable.Symbol.Schema];
|
@@ -38282,7 +38379,7 @@ var init_dialect3 = __esm({
|
|
38282
38379
|
const forceIndexSql2 = this.buildIndex({ indexes: joinMeta.forceIndex, indexFor: "FORCE" });
|
38283
38380
|
const ignoreIndexSql2 = this.buildIndex({ indexes: joinMeta.ignoreIndex, indexFor: "IGNORE" });
|
38284
38381
|
joinsArray.push(
|
38285
|
-
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)}`}
|
38382
|
+
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}`
|
38286
38383
|
);
|
38287
38384
|
} else if (is(table22, View3)) {
|
38288
38385
|
const viewName = table22[ViewBaseConfig].name;
|
@@ -38290,11 +38387,11 @@ var init_dialect3 = __esm({
|
|
38290
38387
|
const origViewName = table22[ViewBaseConfig].originalName;
|
38291
38388
|
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
38292
38389
|
joinsArray.push(
|
38293
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}
|
38390
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
38294
38391
|
);
|
38295
38392
|
} else {
|
38296
38393
|
joinsArray.push(
|
38297
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}
|
38394
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}${onSql}`
|
38298
38395
|
);
|
38299
38396
|
}
|
38300
38397
|
if (index6 < joins.length - 1) {
|
@@ -38317,7 +38414,7 @@ var init_dialect3 = __esm({
|
|
38317
38414
|
const { config, strength } = lockingClause;
|
38318
38415
|
lockingClausesSql = sql` for ${sql.raw(strength)}`;
|
38319
38416
|
if (config.noWait) {
|
38320
|
-
lockingClausesSql.append(sql`
|
38417
|
+
lockingClausesSql.append(sql` nowait`);
|
38321
38418
|
} else if (config.skipLocked) {
|
38322
38419
|
lockingClausesSql.append(sql` skip locked`);
|
38323
38420
|
}
|
@@ -39184,17 +39281,18 @@ var init_select4 = __esm({
|
|
39184
39281
|
*
|
39185
39282
|
* @param table the table to join.
|
39186
39283
|
* @param on the `on` clause.
|
39284
|
+
* @param onIndex index hint.
|
39187
39285
|
*
|
39188
39286
|
* @example
|
39189
39287
|
*
|
39190
39288
|
* ```ts
|
39191
39289
|
* // Select all users and their pets
|
39192
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
39290
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
39193
39291
|
* .from(users)
|
39194
39292
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
39195
39293
|
*
|
39196
39294
|
* // Select userId and petId
|
39197
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
39295
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
39198
39296
|
* userId: users.id,
|
39199
39297
|
* petId: pets.id,
|
39200
39298
|
* })
|
@@ -39202,7 +39300,7 @@ var init_select4 = __esm({
|
|
39202
39300
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
39203
39301
|
*
|
39204
39302
|
* // Select userId and petId with use index hint
|
39205
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
39303
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
39206
39304
|
* userId: users.id,
|
39207
39305
|
* petId: pets.id,
|
39208
39306
|
* })
|
@@ -39212,7 +39310,20 @@ var init_select4 = __esm({
|
|
39212
39310
|
* })
|
39213
39311
|
* ```
|
39214
39312
|
*/
|
39215
|
-
__publicField(this, "leftJoin", this.createJoin("left"));
|
39313
|
+
__publicField(this, "leftJoin", this.createJoin("left", false));
|
39314
|
+
/**
|
39315
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
39316
|
+
*
|
39317
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
39318
|
+
*
|
39319
|
+
* 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.
|
39320
|
+
*
|
39321
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
39322
|
+
*
|
39323
|
+
* @param table the subquery to join.
|
39324
|
+
* @param on the `on` clause.
|
39325
|
+
*/
|
39326
|
+
__publicField(this, "leftJoinLateral", this.createJoin("left", true));
|
39216
39327
|
/**
|
39217
39328
|
* Executes a `right join` operation by adding another table to the current query.
|
39218
39329
|
*
|
@@ -39222,17 +39333,18 @@ var init_select4 = __esm({
|
|
39222
39333
|
*
|
39223
39334
|
* @param table the table to join.
|
39224
39335
|
* @param on the `on` clause.
|
39336
|
+
* @param onIndex index hint.
|
39225
39337
|
*
|
39226
39338
|
* @example
|
39227
39339
|
*
|
39228
39340
|
* ```ts
|
39229
39341
|
* // Select all users and their pets
|
39230
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
39342
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
39231
39343
|
* .from(users)
|
39232
39344
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
39233
39345
|
*
|
39234
39346
|
* // Select userId and petId
|
39235
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
39347
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
39236
39348
|
* userId: users.id,
|
39237
39349
|
* petId: pets.id,
|
39238
39350
|
* })
|
@@ -39240,7 +39352,7 @@ var init_select4 = __esm({
|
|
39240
39352
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
39241
39353
|
*
|
39242
39354
|
* // Select userId and petId with use index hint
|
39243
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
39355
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
39244
39356
|
* userId: users.id,
|
39245
39357
|
* petId: pets.id,
|
39246
39358
|
* })
|
@@ -39250,7 +39362,7 @@ var init_select4 = __esm({
|
|
39250
39362
|
* })
|
39251
39363
|
* ```
|
39252
39364
|
*/
|
39253
|
-
__publicField(this, "rightJoin", this.createJoin("right"));
|
39365
|
+
__publicField(this, "rightJoin", this.createJoin("right", false));
|
39254
39366
|
/**
|
39255
39367
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
39256
39368
|
*
|
@@ -39260,17 +39372,18 @@ var init_select4 = __esm({
|
|
39260
39372
|
*
|
39261
39373
|
* @param table the table to join.
|
39262
39374
|
* @param on the `on` clause.
|
39375
|
+
* @param onIndex index hint.
|
39263
39376
|
*
|
39264
39377
|
* @example
|
39265
39378
|
*
|
39266
39379
|
* ```ts
|
39267
39380
|
* // Select all users and their pets
|
39268
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
39381
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
39269
39382
|
* .from(users)
|
39270
39383
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
39271
39384
|
*
|
39272
39385
|
* // Select userId and petId
|
39273
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
39386
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
39274
39387
|
* userId: users.id,
|
39275
39388
|
* petId: pets.id,
|
39276
39389
|
* })
|
@@ -39278,7 +39391,7 @@ var init_select4 = __esm({
|
|
39278
39391
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
39279
39392
|
*
|
39280
39393
|
* // Select userId and petId with use index hint
|
39281
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
39394
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
39282
39395
|
* userId: users.id,
|
39283
39396
|
* petId: pets.id,
|
39284
39397
|
* })
|
@@ -39288,45 +39401,70 @@ var init_select4 = __esm({
|
|
39288
39401
|
* })
|
39289
39402
|
* ```
|
39290
39403
|
*/
|
39291
|
-
__publicField(this, "innerJoin", this.createJoin("inner"));
|
39404
|
+
__publicField(this, "innerJoin", this.createJoin("inner", false));
|
39292
39405
|
/**
|
39293
|
-
* Executes
|
39406
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
39294
39407
|
*
|
39295
|
-
*
|
39408
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
39296
39409
|
*
|
39297
|
-
*
|
39410
|
+
* 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.
|
39298
39411
|
*
|
39299
|
-
*
|
39412
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
39413
|
+
*
|
39414
|
+
* @param table the subquery to join.
|
39300
39415
|
* @param on the `on` clause.
|
39416
|
+
*/
|
39417
|
+
__publicField(this, "innerJoinLateral", this.createJoin("inner", true));
|
39418
|
+
/**
|
39419
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
39420
|
+
*
|
39421
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
39422
|
+
*
|
39423
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
39424
|
+
*
|
39425
|
+
* @param table the table to join.
|
39426
|
+
* @param onIndex index hint.
|
39301
39427
|
*
|
39302
39428
|
* @example
|
39303
39429
|
*
|
39304
39430
|
* ```ts
|
39305
|
-
* // Select all users
|
39306
|
-
* const usersWithPets: { user: User
|
39431
|
+
* // Select all users, each user with every pet
|
39432
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
39307
39433
|
* .from(users)
|
39308
|
-
* .
|
39434
|
+
* .crossJoin(pets)
|
39309
39435
|
*
|
39310
39436
|
* // Select userId and petId
|
39311
|
-
* const usersIdsAndPetIds: { userId: number
|
39437
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
39312
39438
|
* userId: users.id,
|
39313
39439
|
* petId: pets.id,
|
39314
39440
|
* })
|
39315
39441
|
* .from(users)
|
39316
|
-
* .
|
39442
|
+
* .crossJoin(pets)
|
39317
39443
|
*
|
39318
39444
|
* // Select userId and petId with use index hint
|
39319
|
-
* const usersIdsAndPetIds: { userId: number; petId: number
|
39445
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
39320
39446
|
* userId: users.id,
|
39321
39447
|
* petId: pets.id,
|
39322
39448
|
* })
|
39323
39449
|
* .from(users)
|
39324
|
-
* .
|
39450
|
+
* .crossJoin(pets, {
|
39325
39451
|
* useIndex: ['pets_owner_id_index']
|
39326
39452
|
* })
|
39327
39453
|
* ```
|
39328
39454
|
*/
|
39329
|
-
__publicField(this, "
|
39455
|
+
__publicField(this, "crossJoin", this.createJoin("cross", false));
|
39456
|
+
/**
|
39457
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
39458
|
+
*
|
39459
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
39460
|
+
*
|
39461
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
39462
|
+
*
|
39463
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
39464
|
+
*
|
39465
|
+
* @param table the query to join.
|
39466
|
+
*/
|
39467
|
+
__publicField(this, "crossJoinLateral", this.createJoin("cross", true));
|
39330
39468
|
/**
|
39331
39469
|
* Adds `union` set operator to the query.
|
39332
39470
|
*
|
@@ -39532,8 +39670,11 @@ var init_select4 = __esm({
|
|
39532
39670
|
this.tableName = getTableLikeName(table6);
|
39533
39671
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
39534
39672
|
}
|
39535
|
-
createJoin(joinType) {
|
39536
|
-
return (table6,
|
39673
|
+
createJoin(joinType, lateral) {
|
39674
|
+
return (table6, a, b) => {
|
39675
|
+
const isCrossJoin = joinType === "cross";
|
39676
|
+
let on = isCrossJoin ? void 0 : a;
|
39677
|
+
const onIndex = isCrossJoin ? a : b;
|
39537
39678
|
const baseTableName = this.tableName;
|
39538
39679
|
const tableName = getTableLikeName(table6);
|
39539
39680
|
if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
|
@@ -39575,7 +39716,7 @@ var init_select4 = __esm({
|
|
39575
39716
|
ignoreIndex = convertIndexToString(toArray(onIndex.ignoreIndex));
|
39576
39717
|
}
|
39577
39718
|
}
|
39578
|
-
this.config.joins.push({ on, table: table6, joinType, alias: tableName, useIndex, forceIndex, ignoreIndex });
|
39719
|
+
this.config.joins.push({ on, table: table6, joinType, alias: tableName, useIndex, forceIndex, ignoreIndex, lateral });
|
39579
39720
|
if (typeof tableName === "string") {
|
39580
39721
|
switch (joinType) {
|
39581
39722
|
case "left": {
|
@@ -39589,17 +39730,11 @@ var init_select4 = __esm({
|
|
39589
39730
|
this.joinsNotNullableMap[tableName] = true;
|
39590
39731
|
break;
|
39591
39732
|
}
|
39733
|
+
case "cross":
|
39592
39734
|
case "inner": {
|
39593
39735
|
this.joinsNotNullableMap[tableName] = true;
|
39594
39736
|
break;
|
39595
39737
|
}
|
39596
|
-
case "full": {
|
39597
|
-
this.joinsNotNullableMap = Object.fromEntries(
|
39598
|
-
Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
|
39599
|
-
);
|
39600
|
-
this.joinsNotNullableMap[tableName] = false;
|
39601
|
-
break;
|
39602
|
-
}
|
39603
39738
|
}
|
39604
39739
|
}
|
39605
39740
|
return this;
|
@@ -44093,13 +44228,14 @@ var init_dialect4 = __esm({
|
|
44093
44228
|
}
|
44094
44229
|
const table22 = joinMeta.table;
|
44095
44230
|
const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
|
44231
|
+
const onSql = joinMeta.on ? sql` on ${joinMeta.on}` : void 0;
|
44096
44232
|
if (is(table22, SingleStoreTable)) {
|
44097
44233
|
const tableName = table22[SingleStoreTable.Symbol.Name];
|
44098
44234
|
const tableSchema = table22[SingleStoreTable.Symbol.Schema];
|
44099
44235
|
const origTableName = table22[SingleStoreTable.Symbol.OriginalName];
|
44100
44236
|
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
44101
44237
|
joinsArray.push(
|
44102
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}
|
44238
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
44103
44239
|
);
|
44104
44240
|
} else if (is(table22, View3)) {
|
44105
44241
|
const viewName = table22[ViewBaseConfig].name;
|
@@ -44107,11 +44243,11 @@ var init_dialect4 = __esm({
|
|
44107
44243
|
const origViewName = table22[ViewBaseConfig].originalName;
|
44108
44244
|
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
44109
44245
|
joinsArray.push(
|
44110
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}
|
44246
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`}${onSql}`
|
44111
44247
|
);
|
44112
44248
|
} else {
|
44113
44249
|
joinsArray.push(
|
44114
|
-
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}
|
44250
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table22}${onSql}`
|
44115
44251
|
);
|
44116
44252
|
}
|
44117
44253
|
if (index6 < joins.length - 1) {
|
@@ -44131,7 +44267,7 @@ var init_dialect4 = __esm({
|
|
44131
44267
|
const { config, strength } = lockingClause;
|
44132
44268
|
lockingClausesSql = sql` for ${sql.raw(strength)}`;
|
44133
44269
|
if (config.noWait) {
|
44134
|
-
lockingClausesSql.append(sql`
|
44270
|
+
lockingClausesSql.append(sql` nowait`);
|
44135
44271
|
} else if (config.skipLocked) {
|
44136
44272
|
lockingClausesSql.append(sql` skip locked`);
|
44137
44273
|
}
|
@@ -44571,12 +44707,12 @@ var init_select5 = __esm({
|
|
44571
44707
|
*
|
44572
44708
|
* ```ts
|
44573
44709
|
* // Select all users and their pets
|
44574
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
44710
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
44575
44711
|
* .from(users)
|
44576
44712
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
44577
44713
|
*
|
44578
44714
|
* // Select userId and petId
|
44579
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
44715
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
44580
44716
|
* userId: users.id,
|
44581
44717
|
* petId: pets.id,
|
44582
44718
|
* })
|
@@ -44584,7 +44720,20 @@ var init_select5 = __esm({
|
|
44584
44720
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
44585
44721
|
* ```
|
44586
44722
|
*/
|
44587
|
-
__publicField(this, "leftJoin", this.createJoin("left"));
|
44723
|
+
__publicField(this, "leftJoin", this.createJoin("left", false));
|
44724
|
+
/**
|
44725
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
44726
|
+
*
|
44727
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
44728
|
+
*
|
44729
|
+
* 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.
|
44730
|
+
*
|
44731
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
44732
|
+
*
|
44733
|
+
* @param table the subquery to join.
|
44734
|
+
* @param on the `on` clause.
|
44735
|
+
*/
|
44736
|
+
__publicField(this, "leftJoinLateral", this.createJoin("left", true));
|
44588
44737
|
/**
|
44589
44738
|
* Executes a `right join` operation by adding another table to the current query.
|
44590
44739
|
*
|
@@ -44599,12 +44748,12 @@ var init_select5 = __esm({
|
|
44599
44748
|
*
|
44600
44749
|
* ```ts
|
44601
44750
|
* // Select all users and their pets
|
44602
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
44751
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
44603
44752
|
* .from(users)
|
44604
44753
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
44605
44754
|
*
|
44606
44755
|
* // Select userId and petId
|
44607
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
44756
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
44608
44757
|
* userId: users.id,
|
44609
44758
|
* petId: pets.id,
|
44610
44759
|
* })
|
@@ -44612,7 +44761,7 @@ var init_select5 = __esm({
|
|
44612
44761
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
44613
44762
|
* ```
|
44614
44763
|
*/
|
44615
|
-
__publicField(this, "rightJoin", this.createJoin("right"));
|
44764
|
+
__publicField(this, "rightJoin", this.createJoin("right", false));
|
44616
44765
|
/**
|
44617
44766
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
44618
44767
|
*
|
@@ -44627,12 +44776,12 @@ var init_select5 = __esm({
|
|
44627
44776
|
*
|
44628
44777
|
* ```ts
|
44629
44778
|
* // Select all users and their pets
|
44630
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
44779
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
44631
44780
|
* .from(users)
|
44632
44781
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
44633
44782
|
*
|
44634
44783
|
* // Select userId and petId
|
44635
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
44784
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
44636
44785
|
* userId: users.id,
|
44637
44786
|
* petId: pets.id,
|
44638
44787
|
* })
|
@@ -44640,7 +44789,20 @@ var init_select5 = __esm({
|
|
44640
44789
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
44641
44790
|
* ```
|
44642
44791
|
*/
|
44643
|
-
__publicField(this, "innerJoin", this.createJoin("inner"));
|
44792
|
+
__publicField(this, "innerJoin", this.createJoin("inner", false));
|
44793
|
+
/**
|
44794
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
44795
|
+
*
|
44796
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
44797
|
+
*
|
44798
|
+
* 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.
|
44799
|
+
*
|
44800
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
44801
|
+
*
|
44802
|
+
* @param table the subquery to join.
|
44803
|
+
* @param on the `on` clause.
|
44804
|
+
*/
|
44805
|
+
__publicField(this, "innerJoinLateral", this.createJoin("inner", true));
|
44644
44806
|
/**
|
44645
44807
|
* Executes a `full join` operation by combining rows from two tables into a new table.
|
44646
44808
|
*
|
@@ -44655,12 +44817,12 @@ var init_select5 = __esm({
|
|
44655
44817
|
*
|
44656
44818
|
* ```ts
|
44657
44819
|
* // Select all users and their pets
|
44658
|
-
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
44820
|
+
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
44659
44821
|
* .from(users)
|
44660
44822
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
44661
44823
|
*
|
44662
44824
|
* // Select userId and petId
|
44663
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
44825
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
44664
44826
|
* userId: users.id,
|
44665
44827
|
* petId: pets.id,
|
44666
44828
|
* })
|
@@ -44668,7 +44830,46 @@ var init_select5 = __esm({
|
|
44668
44830
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
44669
44831
|
* ```
|
44670
44832
|
*/
|
44671
|
-
__publicField(this, "fullJoin", this.createJoin("full"));
|
44833
|
+
__publicField(this, "fullJoin", this.createJoin("full", false));
|
44834
|
+
/**
|
44835
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
44836
|
+
*
|
44837
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
44838
|
+
*
|
44839
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
44840
|
+
*
|
44841
|
+
* @param table the table to join.
|
44842
|
+
*
|
44843
|
+
* @example
|
44844
|
+
*
|
44845
|
+
* ```ts
|
44846
|
+
* // Select all users, each user with every pet
|
44847
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
44848
|
+
* .from(users)
|
44849
|
+
* .crossJoin(pets)
|
44850
|
+
*
|
44851
|
+
* // Select userId and petId
|
44852
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
44853
|
+
* userId: users.id,
|
44854
|
+
* petId: pets.id,
|
44855
|
+
* })
|
44856
|
+
* .from(users)
|
44857
|
+
* .crossJoin(pets)
|
44858
|
+
* ```
|
44859
|
+
*/
|
44860
|
+
__publicField(this, "crossJoin", this.createJoin("cross", false));
|
44861
|
+
/**
|
44862
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
44863
|
+
*
|
44864
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
44865
|
+
*
|
44866
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
44867
|
+
*
|
44868
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
44869
|
+
*
|
44870
|
+
* @param table the query to join.
|
44871
|
+
*/
|
44872
|
+
__publicField(this, "crossJoinLateral", this.createJoin("cross", true));
|
44672
44873
|
/**
|
44673
44874
|
* Adds `union` set operator to the query.
|
44674
44875
|
*
|
@@ -44813,7 +45014,7 @@ var init_select5 = __esm({
|
|
44813
45014
|
this.tableName = getTableLikeName(table6);
|
44814
45015
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
44815
45016
|
}
|
44816
|
-
createJoin(joinType) {
|
45017
|
+
createJoin(joinType, lateral) {
|
44817
45018
|
return (table6, on) => {
|
44818
45019
|
const baseTableName = this.tableName;
|
44819
45020
|
const tableName = getTableLikeName(table6);
|
@@ -44842,7 +45043,7 @@ var init_select5 = __esm({
|
|
44842
45043
|
if (!this.config.joins) {
|
44843
45044
|
this.config.joins = [];
|
44844
45045
|
}
|
44845
|
-
this.config.joins.push({ on, table: table6, joinType, alias: tableName });
|
45046
|
+
this.config.joins.push({ on, table: table6, joinType, alias: tableName, lateral });
|
44846
45047
|
if (typeof tableName === "string") {
|
44847
45048
|
switch (joinType) {
|
44848
45049
|
case "left": {
|
@@ -44856,6 +45057,7 @@ var init_select5 = __esm({
|
|
44856
45057
|
this.joinsNotNullableMap[tableName] = true;
|
44857
45058
|
break;
|
44858
45059
|
}
|
45060
|
+
case "cross":
|
44859
45061
|
case "inner": {
|
44860
45062
|
this.joinsNotNullableMap[tableName] = true;
|
44861
45063
|
break;
|