drizzle-orm 0.41.0 → 0.43.0-e2b296d
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/gel-core/dialect.cjs +7 -22
- package/gel-core/dialect.cjs.map +1 -1
- package/gel-core/dialect.d.cts +1 -0
- package/gel-core/dialect.d.ts +1 -0
- package/gel-core/dialect.js +7 -22
- package/gel-core/dialect.js.map +1 -1
- package/gel-core/expressions.cjs +3 -3
- package/gel-core/expressions.cjs.map +1 -1
- package/gel-core/expressions.d.cts +1 -1
- package/gel-core/expressions.d.ts +1 -1
- package/gel-core/expressions.js +2 -2
- package/gel-core/expressions.js.map +1 -1
- package/gel-core/query-builders/select.cjs +80 -14
- package/gel-core/query-builders/select.cjs.map +1 -1
- package/gel-core/query-builders/select.d.cts +78 -13
- package/gel-core/query-builders/select.d.ts +78 -13
- package/gel-core/query-builders/select.js +80 -14
- package/gel-core/query-builders/select.js.map +1 -1
- package/gel-core/query-builders/select.types.cjs.map +1 -1
- package/gel-core/query-builders/select.types.d.cts +1 -1
- package/gel-core/query-builders/select.types.d.ts +1 -1
- package/index.cjs +0 -2
- package/index.cjs.map +1 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/mysql-core/columns/enum.cjs +40 -5
- package/mysql-core/columns/enum.cjs.map +1 -1
- package/mysql-core/columns/enum.d.cts +25 -2
- package/mysql-core/columns/enum.d.ts +25 -2
- package/mysql-core/columns/enum.js +38 -5
- package/mysql-core/columns/enum.js.map +1 -1
- package/mysql-core/dialect.cjs +5 -4
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.js +5 -4
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/expressions.cjs +3 -3
- package/mysql-core/expressions.cjs.map +1 -1
- package/mysql-core/expressions.d.cts +1 -1
- package/mysql-core/expressions.d.ts +1 -1
- package/mysql-core/expressions.js +2 -2
- package/mysql-core/expressions.js.map +1 -1
- package/mysql-core/query-builders/select.cjs +72 -34
- package/mysql-core/query-builders/select.cjs.map +1 -1
- package/mysql-core/query-builders/select.d.cts +66 -25
- package/mysql-core/query-builders/select.d.ts +66 -25
- package/mysql-core/query-builders/select.js +72 -34
- package/mysql-core/query-builders/select.js.map +1 -1
- package/mysql-core/query-builders/select.types.cjs.map +1 -1
- package/mysql-core/query-builders/select.types.d.cts +5 -4
- package/mysql-core/query-builders/select.types.d.ts +5 -4
- package/operations.cjs.map +1 -1
- package/operations.d.cts +5 -1
- package/operations.d.ts +5 -1
- package/package.json +55 -65
- package/pg-core/columns/enum.cjs +46 -2
- package/pg-core/columns/enum.cjs.map +1 -1
- package/pg-core/columns/enum.d.cts +39 -1
- package/pg-core/columns/enum.d.ts +39 -1
- package/pg-core/columns/enum.js +43 -2
- package/pg-core/columns/enum.js.map +1 -1
- package/pg-core/columns/text.cjs.map +1 -1
- package/pg-core/columns/text.d.cts +1 -2
- package/pg-core/columns/text.d.ts +1 -2
- package/pg-core/columns/text.js.map +1 -1
- package/pg-core/dialect.cjs +4 -3
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.js +4 -3
- package/pg-core/dialect.js.map +1 -1
- package/pg-core/expressions.cjs +3 -3
- package/pg-core/expressions.cjs.map +1 -1
- package/pg-core/expressions.d.cts +1 -1
- package/pg-core/expressions.d.ts +1 -1
- package/pg-core/expressions.js +2 -2
- package/pg-core/expressions.js.map +1 -1
- package/pg-core/query-builders/select.cjs +80 -14
- package/pg-core/query-builders/select.cjs.map +1 -1
- package/pg-core/query-builders/select.d.cts +78 -13
- package/pg-core/query-builders/select.d.ts +78 -13
- package/pg-core/query-builders/select.js +80 -14
- package/pg-core/query-builders/select.js.map +1 -1
- package/pg-core/query-builders/select.types.cjs.map +1 -1
- package/pg-core/query-builders/select.types.d.cts +1 -1
- package/pg-core/query-builders/select.types.d.ts +1 -1
- package/pg-core/schema.cjs +6 -2
- package/pg-core/schema.cjs.map +1 -1
- package/pg-core/schema.d.cts +1 -2
- package/pg-core/schema.d.ts +1 -2
- package/pg-core/schema.js +7 -3
- package/pg-core/schema.js.map +1 -1
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.js.map +1 -1
- package/query-builders/select.types.cjs.map +1 -1
- package/query-builders/select.types.d.cts +3 -1
- package/query-builders/select.types.d.ts +3 -1
- package/relations.d.cts +6 -6
- package/relations.d.ts +6 -6
- package/singlestore/driver.cjs +24 -2
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +3 -5
- package/singlestore/driver.d.ts +3 -5
- package/singlestore/driver.js +24 -2
- package/singlestore/driver.js.map +1 -1
- package/singlestore-core/dialect.cjs +5 -4
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.js +5 -4
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/expressions.cjs +3 -3
- package/singlestore-core/expressions.cjs.map +1 -1
- package/singlestore-core/expressions.d.cts +1 -1
- package/singlestore-core/expressions.d.ts +1 -1
- package/singlestore-core/expressions.js +2 -2
- package/singlestore-core/expressions.js.map +1 -1
- package/singlestore-core/query-builders/select.cjs +80 -14
- package/singlestore-core/query-builders/select.cjs.map +1 -1
- package/singlestore-core/query-builders/select.d.cts +78 -13
- package/singlestore-core/query-builders/select.d.ts +78 -13
- package/singlestore-core/query-builders/select.js +80 -14
- package/singlestore-core/query-builders/select.js.map +1 -1
- package/singlestore-core/query-builders/select.types.cjs.map +1 -1
- package/singlestore-core/query-builders/select.types.d.cts +1 -2
- package/singlestore-core/query-builders/select.types.d.ts +1 -2
- package/sql/expressions/conditions.cjs.map +1 -1
- package/sql/expressions/conditions.d.cts +2 -2
- package/sql/expressions/conditions.d.ts +2 -2
- package/sql/expressions/conditions.js.map +1 -1
- package/sqlite-core/dialect.cjs +3 -2
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.js +3 -2
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/expressions.cjs +3 -3
- package/sqlite-core/expressions.cjs.map +1 -1
- package/sqlite-core/expressions.d.cts +1 -1
- package/sqlite-core/expressions.d.ts +1 -1
- package/sqlite-core/expressions.js +2 -2
- package/sqlite-core/expressions.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs +36 -8
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +40 -13
- package/sqlite-core/query-builders/select.d.ts +40 -13
- package/sqlite-core/query-builders/select.js +36 -8
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/select.types.cjs.map +1 -1
- package/sqlite-core/query-builders/select.types.d.cts +1 -1
- package/sqlite-core/query-builders/select.types.d.ts +1 -1
- package/table.cjs.map +1 -1
- package/table.d.cts +3 -0
- package/table.d.ts +3 -0
- package/table.js.map +1 -1
- package/utils.cjs.map +1 -1
- package/utils.d.cts +1 -0
- package/utils.d.ts +1 -0
- package/utils.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/expressions.cjs +0 -23
- package/expressions.cjs.map +0 -1
- package/expressions.d.cts +0 -1
- package/expressions.d.ts +0 -1
- package/expressions.js +0 -2
- package/expressions.js.map +0 -1
|
@@ -13,7 +13,7 @@ import { Subquery } from "../../subquery.cjs";
|
|
|
13
13
|
import type { ValueOrArray } from "../../utils.cjs";
|
|
14
14
|
import type { IndexBuilder } from "../indexes.cjs";
|
|
15
15
|
import { MySqlViewBase } from "../view-base.cjs";
|
|
16
|
-
import type { CreateMySqlSelectFromBuilderMode, GetMySqlSetOperators, LockConfig, LockStrength, MySqlCreateSetOperatorFn,
|
|
16
|
+
import type { CreateMySqlSelectFromBuilderMode, GetMySqlSetOperators, LockConfig, LockStrength, MySqlCreateSetOperatorFn, MySqlSelectConfig, MySqlSelectDynamic, MySqlSelectHKT, MySqlSelectHKTBase, MySqlSelectPrepare, MySqlSelectWithout, MySqlSetOperatorExcludedMethods, MySqlSetOperatorWithResult, SelectedFields, SetOperatorRightSelect } from "./select.types.cjs";
|
|
17
17
|
export type IndexForHint = IndexBuilder | string;
|
|
18
18
|
export type IndexConfig = {
|
|
19
19
|
useIndex?: IndexForHint | IndexForHint[];
|
|
@@ -77,17 +77,18 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
77
77
|
*
|
|
78
78
|
* @param table the table to join.
|
|
79
79
|
* @param on the `on` clause.
|
|
80
|
+
* @param onIndex index hint.
|
|
80
81
|
*
|
|
81
82
|
* @example
|
|
82
83
|
*
|
|
83
84
|
* ```ts
|
|
84
85
|
* // Select all users and their pets
|
|
85
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
|
86
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
|
86
87
|
* .from(users)
|
|
87
88
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
88
89
|
*
|
|
89
90
|
* // Select userId and petId
|
|
90
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
91
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
91
92
|
* userId: users.id,
|
|
92
93
|
* petId: pets.id,
|
|
93
94
|
* })
|
|
@@ -95,7 +96,7 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
95
96
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
96
97
|
*
|
|
97
98
|
* // Select userId and petId with use index hint
|
|
98
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
99
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
99
100
|
* userId: users.id,
|
|
100
101
|
* petId: pets.id,
|
|
101
102
|
* })
|
|
@@ -105,7 +106,20 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
105
106
|
* })
|
|
106
107
|
* ```
|
|
107
108
|
*/
|
|
108
|
-
leftJoin:
|
|
109
|
+
leftJoin: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>> | MySqlTable<import("../table.ts").TableConfig> | MySqlViewBase<string, boolean, ColumnsSelection>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: SQL<unknown> | ((aliases: this["_"]["selection"]) => SQL | undefined) | undefined, onIndex?: (TJoinedTable extends MySqlTable<import("../table.ts").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.ts").MySqlJoin<this, TDynamic, "left", TJoinedTable, TJoinedName>;
|
|
110
|
+
/**
|
|
111
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
|
112
|
+
*
|
|
113
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
114
|
+
*
|
|
115
|
+
* 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.
|
|
116
|
+
*
|
|
117
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
|
118
|
+
*
|
|
119
|
+
* @param table the subquery to join.
|
|
120
|
+
* @param on the `on` clause.
|
|
121
|
+
*/
|
|
122
|
+
leftJoinLateral: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: SQL<unknown> | ((aliases: this["_"]["selection"]) => SQL | undefined) | undefined, onIndex?: (TJoinedTable extends MySqlTable<import("../table.ts").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.ts").MySqlJoin<this, TDynamic, "left", TJoinedTable, TJoinedName>;
|
|
109
123
|
/**
|
|
110
124
|
* Executes a `right join` operation by adding another table to the current query.
|
|
111
125
|
*
|
|
@@ -115,17 +129,18 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
115
129
|
*
|
|
116
130
|
* @param table the table to join.
|
|
117
131
|
* @param on the `on` clause.
|
|
132
|
+
* @param onIndex index hint.
|
|
118
133
|
*
|
|
119
134
|
* @example
|
|
120
135
|
*
|
|
121
136
|
* ```ts
|
|
122
137
|
* // Select all users and their pets
|
|
123
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
|
138
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
|
124
139
|
* .from(users)
|
|
125
140
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
126
141
|
*
|
|
127
142
|
* // Select userId and petId
|
|
128
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
|
143
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
|
129
144
|
* userId: users.id,
|
|
130
145
|
* petId: pets.id,
|
|
131
146
|
* })
|
|
@@ -133,7 +148,7 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
133
148
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
134
149
|
*
|
|
135
150
|
* // Select userId and petId with use index hint
|
|
136
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
151
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
137
152
|
* userId: users.id,
|
|
138
153
|
* petId: pets.id,
|
|
139
154
|
* })
|
|
@@ -143,7 +158,7 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
143
158
|
* })
|
|
144
159
|
* ```
|
|
145
160
|
*/
|
|
146
|
-
rightJoin:
|
|
161
|
+
rightJoin: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>> | MySqlTable<import("../table.ts").TableConfig> | MySqlViewBase<string, boolean, ColumnsSelection>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: SQL<unknown> | ((aliases: this["_"]["selection"]) => SQL | undefined) | undefined, onIndex?: (TJoinedTable extends MySqlTable<import("../table.ts").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.ts").MySqlJoin<this, TDynamic, "right", TJoinedTable, TJoinedName>;
|
|
147
162
|
/**
|
|
148
163
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
|
149
164
|
*
|
|
@@ -153,17 +168,18 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
153
168
|
*
|
|
154
169
|
* @param table the table to join.
|
|
155
170
|
* @param on the `on` clause.
|
|
171
|
+
* @param onIndex index hint.
|
|
156
172
|
*
|
|
157
173
|
* @example
|
|
158
174
|
*
|
|
159
175
|
* ```ts
|
|
160
176
|
* // Select all users and their pets
|
|
161
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
|
177
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
162
178
|
* .from(users)
|
|
163
179
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
164
180
|
*
|
|
165
181
|
* // Select userId and petId
|
|
166
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
|
182
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
167
183
|
* userId: users.id,
|
|
168
184
|
* petId: pets.id,
|
|
169
185
|
* })
|
|
@@ -171,7 +187,7 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
171
187
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
172
188
|
*
|
|
173
189
|
* // Select userId and petId with use index hint
|
|
174
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
190
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
175
191
|
* userId: users.id,
|
|
176
192
|
* petId: pets.id,
|
|
177
193
|
* })
|
|
@@ -181,45 +197,70 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
181
197
|
* })
|
|
182
198
|
* ```
|
|
183
199
|
*/
|
|
184
|
-
innerJoin:
|
|
200
|
+
innerJoin: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>> | MySqlTable<import("../table.ts").TableConfig> | MySqlViewBase<string, boolean, ColumnsSelection>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: SQL<unknown> | ((aliases: this["_"]["selection"]) => SQL | undefined) | undefined, onIndex?: (TJoinedTable extends MySqlTable<import("../table.ts").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.ts").MySqlJoin<this, TDynamic, "inner", TJoinedTable, TJoinedName>;
|
|
185
201
|
/**
|
|
186
|
-
* Executes
|
|
202
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
|
187
203
|
*
|
|
188
|
-
*
|
|
204
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
189
205
|
*
|
|
190
|
-
*
|
|
206
|
+
* 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.
|
|
191
207
|
*
|
|
192
|
-
*
|
|
208
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
|
209
|
+
*
|
|
210
|
+
* @param table the subquery to join.
|
|
193
211
|
* @param on the `on` clause.
|
|
212
|
+
*/
|
|
213
|
+
innerJoinLateral: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: SQL<unknown> | ((aliases: this["_"]["selection"]) => SQL | undefined) | undefined, onIndex?: (TJoinedTable extends MySqlTable<import("../table.ts").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.ts").MySqlJoin<this, TDynamic, "inner", TJoinedTable, TJoinedName>;
|
|
214
|
+
/**
|
|
215
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
|
216
|
+
*
|
|
217
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
|
218
|
+
*
|
|
219
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
|
220
|
+
*
|
|
221
|
+
* @param table the table to join.
|
|
222
|
+
* @param onIndex index hint.
|
|
194
223
|
*
|
|
195
224
|
* @example
|
|
196
225
|
*
|
|
197
226
|
* ```ts
|
|
198
|
-
* // Select all users
|
|
199
|
-
* const usersWithPets: { user: User
|
|
227
|
+
* // Select all users, each user with every pet
|
|
228
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
200
229
|
* .from(users)
|
|
201
|
-
* .
|
|
230
|
+
* .crossJoin(pets)
|
|
202
231
|
*
|
|
203
232
|
* // Select userId and petId
|
|
204
|
-
* const usersIdsAndPetIds: { userId: number
|
|
233
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
205
234
|
* userId: users.id,
|
|
206
235
|
* petId: pets.id,
|
|
207
236
|
* })
|
|
208
237
|
* .from(users)
|
|
209
|
-
* .
|
|
238
|
+
* .crossJoin(pets)
|
|
210
239
|
*
|
|
211
240
|
* // Select userId and petId with use index hint
|
|
212
|
-
* const usersIdsAndPetIds: { userId: number; petId: number
|
|
241
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
213
242
|
* userId: users.id,
|
|
214
243
|
* petId: pets.id,
|
|
215
244
|
* })
|
|
216
245
|
* .from(users)
|
|
217
|
-
* .
|
|
246
|
+
* .crossJoin(pets, {
|
|
218
247
|
* useIndex: ['pets_owner_id_index']
|
|
219
248
|
* })
|
|
220
249
|
* ```
|
|
221
250
|
*/
|
|
222
|
-
|
|
251
|
+
crossJoin: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>> | MySqlTable<import("../table.ts").TableConfig> | MySqlViewBase<string, boolean, ColumnsSelection>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, onIndex?: (TJoinedTable extends MySqlTable<import("../table.ts").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.ts").MySqlJoin<this, TDynamic, "cross", TJoinedTable, TJoinedName>;
|
|
252
|
+
/**
|
|
253
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
|
254
|
+
*
|
|
255
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
256
|
+
*
|
|
257
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
|
258
|
+
*
|
|
259
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
|
260
|
+
*
|
|
261
|
+
* @param table the query to join.
|
|
262
|
+
*/
|
|
263
|
+
crossJoinLateral: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, onIndex?: (TJoinedTable extends MySqlTable<import("../table.ts").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.ts").MySqlJoin<this, TDynamic, "cross", TJoinedTable, TJoinedName>;
|
|
223
264
|
private createSetOperator;
|
|
224
265
|
/**
|
|
225
266
|
* Adds `union` set operator to the query.
|
|
@@ -13,7 +13,7 @@ import { Subquery } from "../../subquery.js";
|
|
|
13
13
|
import type { ValueOrArray } from "../../utils.js";
|
|
14
14
|
import type { IndexBuilder } from "../indexes.js";
|
|
15
15
|
import { MySqlViewBase } from "../view-base.js";
|
|
16
|
-
import type { CreateMySqlSelectFromBuilderMode, GetMySqlSetOperators, LockConfig, LockStrength, MySqlCreateSetOperatorFn,
|
|
16
|
+
import type { CreateMySqlSelectFromBuilderMode, GetMySqlSetOperators, LockConfig, LockStrength, MySqlCreateSetOperatorFn, MySqlSelectConfig, MySqlSelectDynamic, MySqlSelectHKT, MySqlSelectHKTBase, MySqlSelectPrepare, MySqlSelectWithout, MySqlSetOperatorExcludedMethods, MySqlSetOperatorWithResult, SelectedFields, SetOperatorRightSelect } from "./select.types.js";
|
|
17
17
|
export type IndexForHint = IndexBuilder | string;
|
|
18
18
|
export type IndexConfig = {
|
|
19
19
|
useIndex?: IndexForHint | IndexForHint[];
|
|
@@ -77,17 +77,18 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
77
77
|
*
|
|
78
78
|
* @param table the table to join.
|
|
79
79
|
* @param on the `on` clause.
|
|
80
|
+
* @param onIndex index hint.
|
|
80
81
|
*
|
|
81
82
|
* @example
|
|
82
83
|
*
|
|
83
84
|
* ```ts
|
|
84
85
|
* // Select all users and their pets
|
|
85
|
-
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
|
86
|
+
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
|
86
87
|
* .from(users)
|
|
87
88
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
88
89
|
*
|
|
89
90
|
* // Select userId and petId
|
|
90
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
91
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
91
92
|
* userId: users.id,
|
|
92
93
|
* petId: pets.id,
|
|
93
94
|
* })
|
|
@@ -95,7 +96,7 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
95
96
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
96
97
|
*
|
|
97
98
|
* // Select userId and petId with use index hint
|
|
98
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
99
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
99
100
|
* userId: users.id,
|
|
100
101
|
* petId: pets.id,
|
|
101
102
|
* })
|
|
@@ -105,7 +106,20 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
105
106
|
* })
|
|
106
107
|
* ```
|
|
107
108
|
*/
|
|
108
|
-
leftJoin:
|
|
109
|
+
leftJoin: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>> | MySqlTable<import("../table.js").TableConfig> | MySqlViewBase<string, boolean, ColumnsSelection>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: SQL<unknown> | ((aliases: this["_"]["selection"]) => SQL | undefined) | undefined, onIndex?: (TJoinedTable extends MySqlTable<import("../table.js").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.js").MySqlJoin<this, TDynamic, "left", TJoinedTable, TJoinedName>;
|
|
110
|
+
/**
|
|
111
|
+
* Executes a `left join lateral` operation by adding subquery to the current query.
|
|
112
|
+
*
|
|
113
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
114
|
+
*
|
|
115
|
+
* 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.
|
|
116
|
+
*
|
|
117
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
|
118
|
+
*
|
|
119
|
+
* @param table the subquery to join.
|
|
120
|
+
* @param on the `on` clause.
|
|
121
|
+
*/
|
|
122
|
+
leftJoinLateral: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: SQL<unknown> | ((aliases: this["_"]["selection"]) => SQL | undefined) | undefined, onIndex?: (TJoinedTable extends MySqlTable<import("../table.js").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.js").MySqlJoin<this, TDynamic, "left", TJoinedTable, TJoinedName>;
|
|
109
123
|
/**
|
|
110
124
|
* Executes a `right join` operation by adding another table to the current query.
|
|
111
125
|
*
|
|
@@ -115,17 +129,18 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
115
129
|
*
|
|
116
130
|
* @param table the table to join.
|
|
117
131
|
* @param on the `on` clause.
|
|
132
|
+
* @param onIndex index hint.
|
|
118
133
|
*
|
|
119
134
|
* @example
|
|
120
135
|
*
|
|
121
136
|
* ```ts
|
|
122
137
|
* // Select all users and their pets
|
|
123
|
-
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
|
138
|
+
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
|
124
139
|
* .from(users)
|
|
125
140
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
126
141
|
*
|
|
127
142
|
* // Select userId and petId
|
|
128
|
-
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
|
143
|
+
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
|
129
144
|
* userId: users.id,
|
|
130
145
|
* petId: pets.id,
|
|
131
146
|
* })
|
|
@@ -133,7 +148,7 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
133
148
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
134
149
|
*
|
|
135
150
|
* // Select userId and petId with use index hint
|
|
136
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
151
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
137
152
|
* userId: users.id,
|
|
138
153
|
* petId: pets.id,
|
|
139
154
|
* })
|
|
@@ -143,7 +158,7 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
143
158
|
* })
|
|
144
159
|
* ```
|
|
145
160
|
*/
|
|
146
|
-
rightJoin:
|
|
161
|
+
rightJoin: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>> | MySqlTable<import("../table.js").TableConfig> | MySqlViewBase<string, boolean, ColumnsSelection>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: SQL<unknown> | ((aliases: this["_"]["selection"]) => SQL | undefined) | undefined, onIndex?: (TJoinedTable extends MySqlTable<import("../table.js").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.js").MySqlJoin<this, TDynamic, "right", TJoinedTable, TJoinedName>;
|
|
147
162
|
/**
|
|
148
163
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
|
149
164
|
*
|
|
@@ -153,17 +168,18 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
153
168
|
*
|
|
154
169
|
* @param table the table to join.
|
|
155
170
|
* @param on the `on` clause.
|
|
171
|
+
* @param onIndex index hint.
|
|
156
172
|
*
|
|
157
173
|
* @example
|
|
158
174
|
*
|
|
159
175
|
* ```ts
|
|
160
176
|
* // Select all users and their pets
|
|
161
|
-
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
|
177
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
162
178
|
* .from(users)
|
|
163
179
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
164
180
|
*
|
|
165
181
|
* // Select userId and petId
|
|
166
|
-
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
|
182
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
167
183
|
* userId: users.id,
|
|
168
184
|
* petId: pets.id,
|
|
169
185
|
* })
|
|
@@ -171,7 +187,7 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
171
187
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
172
188
|
*
|
|
173
189
|
* // Select userId and petId with use index hint
|
|
174
|
-
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
190
|
+
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
|
175
191
|
* userId: users.id,
|
|
176
192
|
* petId: pets.id,
|
|
177
193
|
* })
|
|
@@ -181,45 +197,70 @@ export declare abstract class MySqlSelectQueryBuilderBase<THKT extends MySqlSele
|
|
|
181
197
|
* })
|
|
182
198
|
* ```
|
|
183
199
|
*/
|
|
184
|
-
innerJoin:
|
|
200
|
+
innerJoin: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>> | MySqlTable<import("../table.js").TableConfig> | MySqlViewBase<string, boolean, ColumnsSelection>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: SQL<unknown> | ((aliases: this["_"]["selection"]) => SQL | undefined) | undefined, onIndex?: (TJoinedTable extends MySqlTable<import("../table.js").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.js").MySqlJoin<this, TDynamic, "inner", TJoinedTable, TJoinedName>;
|
|
185
201
|
/**
|
|
186
|
-
* Executes
|
|
202
|
+
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
|
187
203
|
*
|
|
188
|
-
*
|
|
204
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
189
205
|
*
|
|
190
|
-
*
|
|
206
|
+
* 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.
|
|
191
207
|
*
|
|
192
|
-
*
|
|
208
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
|
209
|
+
*
|
|
210
|
+
* @param table the subquery to join.
|
|
193
211
|
* @param on the `on` clause.
|
|
212
|
+
*/
|
|
213
|
+
innerJoinLateral: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, on: SQL<unknown> | ((aliases: this["_"]["selection"]) => SQL | undefined) | undefined, onIndex?: (TJoinedTable extends MySqlTable<import("../table.js").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.js").MySqlJoin<this, TDynamic, "inner", TJoinedTable, TJoinedName>;
|
|
214
|
+
/**
|
|
215
|
+
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
|
216
|
+
*
|
|
217
|
+
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
|
218
|
+
*
|
|
219
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
|
220
|
+
*
|
|
221
|
+
* @param table the table to join.
|
|
222
|
+
* @param onIndex index hint.
|
|
194
223
|
*
|
|
195
224
|
* @example
|
|
196
225
|
*
|
|
197
226
|
* ```ts
|
|
198
|
-
* // Select all users
|
|
199
|
-
* const usersWithPets: { user: User
|
|
227
|
+
* // Select all users, each user with every pet
|
|
228
|
+
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
|
200
229
|
* .from(users)
|
|
201
|
-
* .
|
|
230
|
+
* .crossJoin(pets)
|
|
202
231
|
*
|
|
203
232
|
* // Select userId and petId
|
|
204
|
-
* const usersIdsAndPetIds: { userId: number
|
|
233
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
205
234
|
* userId: users.id,
|
|
206
235
|
* petId: pets.id,
|
|
207
236
|
* })
|
|
208
237
|
* .from(users)
|
|
209
|
-
* .
|
|
238
|
+
* .crossJoin(pets)
|
|
210
239
|
*
|
|
211
240
|
* // Select userId and petId with use index hint
|
|
212
|
-
* const usersIdsAndPetIds: { userId: number; petId: number
|
|
241
|
+
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
|
213
242
|
* userId: users.id,
|
|
214
243
|
* petId: pets.id,
|
|
215
244
|
* })
|
|
216
245
|
* .from(users)
|
|
217
|
-
* .
|
|
246
|
+
* .crossJoin(pets, {
|
|
218
247
|
* useIndex: ['pets_owner_id_index']
|
|
219
248
|
* })
|
|
220
249
|
* ```
|
|
221
250
|
*/
|
|
222
|
-
|
|
251
|
+
crossJoin: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>> | MySqlTable<import("../table.js").TableConfig> | MySqlViewBase<string, boolean, ColumnsSelection>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, onIndex?: (TJoinedTable extends MySqlTable<import("../table.js").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.js").MySqlJoin<this, TDynamic, "cross", TJoinedTable, TJoinedName>;
|
|
252
|
+
/**
|
|
253
|
+
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
|
254
|
+
*
|
|
255
|
+
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
|
256
|
+
*
|
|
257
|
+
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
|
258
|
+
*
|
|
259
|
+
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
|
260
|
+
*
|
|
261
|
+
* @param table the query to join.
|
|
262
|
+
*/
|
|
263
|
+
crossJoinLateral: <TJoinedTable extends SQL<unknown> | Subquery<string, Record<string, unknown>>, TJoinedName extends GetSelectTableName<TJoinedTable> = GetSelectTableName<TJoinedTable>>(table: TJoinedTable, onIndex?: (TJoinedTable extends MySqlTable<import("../table.js").TableConfig> ? IndexConfig : "Index hint configuration is allowed only for MySqlTable and not for subqueries or views") | undefined) => import("./select.types.js").MySqlJoin<this, TDynamic, "cross", TJoinedTable, TJoinedName>;
|
|
223
264
|
private createSetOperator;
|
|
224
265
|
/**
|
|
225
266
|
* Adds `union` set operator to the query.
|