Skip to content

Commit 59f0089

Browse files
committed
chore: remove redundant queryId args.
1 parent 5c64caf commit 59f0089

25 files changed

+43
-81
lines changed

src/kysely.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
provideControlledConnection,
4949
} from './util/provide-controlled-connection.js'
5050
import { ConnectionProvider } from './driver/connection-provider.js'
51+
import { logOnce } from './util/log-once.js'
5152

5253
// @ts-ignore
5354
Symbol.asyncDispose ??= Symbol('Symbol.asyncDispose')
@@ -539,11 +540,18 @@ export class Kysely<DB>
539540
*/
540541
executeQuery<R>(
541542
query: CompiledQuery<R> | Compilable<R>,
542-
queryId: QueryId = createQueryId(),
543+
// TODO: remove this in the future. deprecated in 0.28.x
544+
queryId?: QueryId,
543545
): Promise<QueryResult<R>> {
546+
if (queryId !== undefined) {
547+
logOnce(
548+
'Passing `queryId` in `db.executeQuery` is deprecated and will result in a compile-time error in the future.',
549+
)
550+
}
551+
544552
const compiledQuery = isCompilable(query) ? query.compile() : query
545553

546-
return this.getExecutor().executeQuery<R>(compiledQuery, queryId)
554+
return this.getExecutor().executeQuery<R>(compiledQuery)
547555
}
548556

549557
async [Symbol.asyncDispose]() {
@@ -1169,21 +1177,17 @@ class NotCommittedOrRolledBackAssertingExecutor implements QueryExecutor {
11691177
return this.#executor.provideConnection(consumer)
11701178
}
11711179

1172-
executeQuery<R>(
1173-
compiledQuery: CompiledQuery<R>,
1174-
queryId: QueryId,
1175-
): Promise<QueryResult<R>> {
1180+
executeQuery<R>(compiledQuery: CompiledQuery<R>): Promise<QueryResult<R>> {
11761181
assertNotCommittedOrRolledBack(this.#state)
1177-
return this.#executor.executeQuery(compiledQuery, queryId)
1182+
return this.#executor.executeQuery(compiledQuery)
11781183
}
11791184

11801185
stream<R>(
11811186
compiledQuery: CompiledQuery<R>,
11821187
chunkSize: number,
1183-
queryId: QueryId,
11841188
): AsyncIterableIterator<QueryResult<R>> {
11851189
assertNotCommittedOrRolledBack(this.#state)
1186-
return this.#executor.stream(compiledQuery, chunkSize, queryId)
1190+
return this.#executor.stream(compiledQuery, chunkSize)
11871191
}
11881192

11891193
withConnectionProvider(

src/query-builder/delete-query-builder.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,10 +1059,7 @@ export class DeleteQueryBuilder<DB, TB extends keyof DB, O>
10591059
async execute(): Promise<SimplifyResult<O>[]> {
10601060
const compiledQuery = this.compile()
10611061

1062-
const result = await this.#props.executor.executeQuery<O>(
1063-
compiledQuery,
1064-
this.#props.queryId,
1065-
)
1062+
const result = await this.#props.executor.executeQuery<O>(compiledQuery)
10661063

10671064
const { adapter } = this.#props.executor
10681065
const query = compiledQuery.query as DeleteQueryNode
@@ -1115,11 +1112,7 @@ export class DeleteQueryBuilder<DB, TB extends keyof DB, O>
11151112
async *stream(chunkSize: number = 100): AsyncIterableIterator<O> {
11161113
const compiledQuery = this.compile()
11171114

1118-
const stream = this.#props.executor.stream<O>(
1119-
compiledQuery,
1120-
chunkSize,
1121-
this.#props.queryId,
1122-
)
1115+
const stream = this.#props.executor.stream<O>(compiledQuery, chunkSize)
11231116

11241117
for await (const item of stream) {
11251118
yield* item.rows

src/query-builder/insert-query-builder.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,10 +1292,7 @@ export class InsertQueryBuilder<DB, TB extends keyof DB, O>
12921292
async execute(): Promise<SimplifyResult<O>[]> {
12931293
const compiledQuery = this.compile()
12941294

1295-
const result = await this.#props.executor.executeQuery<O>(
1296-
compiledQuery,
1297-
this.#props.queryId,
1298-
)
1295+
const result = await this.#props.executor.executeQuery<O>(compiledQuery)
12991296

13001297
const { adapter } = this.#props.executor
13011298
const query = compiledQuery.query as InsertQueryNode
@@ -1353,11 +1350,7 @@ export class InsertQueryBuilder<DB, TB extends keyof DB, O>
13531350
async *stream(chunkSize: number = 100): AsyncIterableIterator<O> {
13541351
const compiledQuery = this.compile()
13551352

1356-
const stream = this.#props.executor.stream<O>(
1357-
compiledQuery,
1358-
chunkSize,
1359-
this.#props.queryId,
1360-
)
1353+
const stream = this.#props.executor.stream<O>(compiledQuery, chunkSize)
13611354

13621355
for await (const item of stream) {
13631356
yield* item.rows

src/query-builder/merge-query-builder.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -883,10 +883,7 @@ export class WheneableMergeQueryBuilder<
883883
async execute(): Promise<SimplifyResult<O>[]> {
884884
const compiledQuery = this.compile()
885885

886-
const result = await this.#props.executor.executeQuery<O>(
887-
compiledQuery,
888-
this.#props.queryId,
889-
)
886+
const result = await this.#props.executor.executeQuery<O>(compiledQuery)
890887

891888
const { adapter } = this.#props.executor
892889
const query = compiledQuery.query as MergeQueryNode

src/query-builder/select-query-builder.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,10 +2650,7 @@ class SelectQueryBuilderImpl<DB, TB extends keyof DB, O>
26502650
async execute(): Promise<Simplify<O>[]> {
26512651
const compiledQuery = this.compile()
26522652

2653-
const result = await this.#props.executor.executeQuery<O>(
2654-
compiledQuery,
2655-
this.#props.queryId,
2656-
)
2653+
const result = await this.#props.executor.executeQuery<O>(compiledQuery)
26572654

26582655
return result.rows
26592656
}
@@ -2684,11 +2681,7 @@ class SelectQueryBuilderImpl<DB, TB extends keyof DB, O>
26842681
async *stream(chunkSize: number = 100): AsyncIterableIterator<O> {
26852682
const compiledQuery = this.compile()
26862683

2687-
const stream = this.#props.executor.stream<O>(
2688-
compiledQuery,
2689-
chunkSize,
2690-
this.#props.queryId,
2691-
)
2684+
const stream = this.#props.executor.stream<O>(compiledQuery, chunkSize)
26922685

26932686
for await (const item of stream) {
26942687
yield* item.rows

src/query-builder/update-query-builder.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,10 +1148,7 @@ export class UpdateQueryBuilder<DB, UT extends keyof DB, TB extends keyof DB, O>
11481148
async execute(): Promise<SimplifyResult<O>[]> {
11491149
const compiledQuery = this.compile()
11501150

1151-
const result = await this.#props.executor.executeQuery<O>(
1152-
compiledQuery,
1153-
this.#props.queryId,
1154-
)
1151+
const result = await this.#props.executor.executeQuery<O>(compiledQuery)
11551152

11561153
const { adapter } = this.#props.executor
11571154
const query = compiledQuery.query as UpdateQueryNode
@@ -1209,11 +1206,7 @@ export class UpdateQueryBuilder<DB, UT extends keyof DB, TB extends keyof DB, O>
12091206
async *stream(chunkSize: number = 100): AsyncIterableIterator<O> {
12101207
const compiledQuery = this.compile()
12111208

1212-
const stream = this.#props.executor.stream<O>(
1213-
compiledQuery,
1214-
chunkSize,
1215-
this.#props.queryId,
1216-
)
1209+
const stream = this.#props.executor.stream<O>(compiledQuery, chunkSize)
12171210

12181211
for await (const item of stream) {
12191212
yield* item.rows

src/query-executor/query-executor-base.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ export abstract class QueryExecutorBase implements QueryExecutor {
6060
consumer: (connection: DatabaseConnection) => Promise<T>,
6161
): Promise<T>
6262

63-
async executeQuery<R>(
64-
compiledQuery: CompiledQuery,
65-
queryId: QueryId,
66-
): Promise<QueryResult<R>> {
63+
async executeQuery<R>(compiledQuery: CompiledQuery): Promise<QueryResult<R>> {
6764
return await this.provideConnection(async (connection) => {
6865
const result = await connection.executeQuery(compiledQuery)
6966

@@ -73,14 +70,13 @@ export abstract class QueryExecutorBase implements QueryExecutor {
7370
)
7471
}
7572

76-
return await this.#transformResult(result, queryId)
73+
return await this.#transformResult(result, compiledQuery.queryId)
7774
})
7875
}
7976

8077
async *stream<R>(
8178
compiledQuery: CompiledQuery,
8279
chunkSize: number,
83-
queryId: QueryId,
8480
): AsyncIterableIterator<QueryResult<R>> {
8581
const { connection, release } = await provideControlledConnection(this)
8682

@@ -89,7 +85,7 @@ export abstract class QueryExecutorBase implements QueryExecutor {
8985
compiledQuery,
9086
chunkSize,
9187
)) {
92-
yield await this.#transformResult(result, queryId)
88+
yield await this.#transformResult(result, compiledQuery.queryId)
9389
}
9490
} finally {
9591
release()

src/query-executor/query-executor.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ export interface QueryExecutor extends ConnectionProvider {
4444
* Executes a compiled query and runs the result through all plugins'
4545
* `transformResult` method.
4646
*/
47-
executeQuery<R>(
48-
compiledQuery: CompiledQuery<R>,
49-
queryId: QueryId,
50-
): Promise<QueryResult<R>>
47+
executeQuery<R>(compiledQuery: CompiledQuery<R>): Promise<QueryResult<R>>
5148

5249
/**
5350
* Executes a compiled query and runs the result through all plugins'
@@ -61,7 +58,6 @@ export interface QueryExecutor extends ConnectionProvider {
6158
* only by the postgres driver.
6259
*/
6360
chunkSize: number,
64-
queryId: QueryId,
6561
): AsyncIterableIterator<QueryResult<R>>
6662

6763
/**

src/raw-builder/raw-builder.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,7 @@ class RawBuilderImpl<O> implements RawBuilder<O> {
190190
): Promise<QueryResult<O>> {
191191
const executor = this.#getExecutor(executorProvider)
192192

193-
return executor.executeQuery<O>(
194-
this.#compile(executor),
195-
this.#props.queryId,
196-
)
193+
return executor.executeQuery<O>(this.#compile(executor))
197194
}
198195

199196
#getExecutor(executorProvider?: QueryExecutorProvider): QueryExecutor {

src/schema/alter-table-add-foreign-key-constraint-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class AlterTableAddForeignKeyConstraintBuilder
9797
}
9898

9999
async execute(): Promise<void> {
100-
await this.#props.executor.executeQuery(this.compile(), this.#props.queryId)
100+
await this.#props.executor.executeQuery(this.compile())
101101
}
102102
}
103103

0 commit comments

Comments
 (0)