Skip to content

Commit 124c0dc

Browse files
wirekangigalklebanov
authored andcommitted
Remove preventAwait (#1160)
Related #748
1 parent 9819b24 commit 124c0dc

38 files changed

+28
-257
lines changed

src/kysely.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
TransactionSettings,
1717
TRANSACTION_ISOLATION_LEVELS,
1818
} from './driver/driver.js'
19-
import { preventAwait } from './util/prevent-await.js'
2019
import {
2120
createFunctionModule,
2221
FunctionModule,
@@ -526,11 +525,6 @@ export class ConnectionBuilder<DB> {
526525

527526
interface ConnectionBuilderProps extends KyselyProps {}
528527

529-
preventAwait(
530-
ConnectionBuilder,
531-
"don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method",
532-
)
533-
534528
export class TransactionBuilder<DB> {
535529
readonly #props: TransactionBuilderProps
536530

@@ -579,11 +573,6 @@ interface TransactionBuilderProps extends KyselyProps {
579573
readonly isolationLevel?: IsolationLevel
580574
}
581575

582-
preventAwait(
583-
TransactionBuilder,
584-
"don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method",
585-
)
586-
587576
function validateTransactionSettings(settings: TransactionSettings): void {
588577
if (
589578
settings.isolationLevel &&

src/operation-node/operation-node-transformer.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ export class OperationNodeTransformer {
190190
DropConstraintNode: this.transformDropConstraint.bind(this),
191191
ForeignKeyConstraintNode: this.transformForeignKeyConstraint.bind(this),
192192
CreateViewNode: this.transformCreateView.bind(this),
193-
RefreshMaterializedViewNode: this.transformRefreshMaterializedView.bind(this),
193+
RefreshMaterializedViewNode:
194+
this.transformRefreshMaterializedView.bind(this),
194195
DropViewNode: this.transformDropView.bind(this),
195196
GeneratedNode: this.transformGenerated.bind(this),
196197
DefaultValueNode: this.transformDefaultValue.bind(this),
@@ -798,7 +799,9 @@ export class OperationNodeTransformer {
798799
})
799800
}
800801

801-
protected transformRefreshMaterializedView(node: RefreshMaterializedViewNode): RefreshMaterializedViewNode {
802+
protected transformRefreshMaterializedView(
803+
node: RefreshMaterializedViewNode,
804+
): RefreshMaterializedViewNode {
802805
return requireAllProps<RefreshMaterializedViewNode>({
803806
kind: 'RefreshMaterializedViewNode',
804807
name: this.transformNode(node.name),

src/operation-node/operation-node-visitor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ export abstract class OperationNodeVisitor {
279279
protected abstract visitPrimitiveValueList(node: PrimitiveValueListNode): void
280280
protected abstract visitOperator(node: OperatorNode): void
281281
protected abstract visitCreateView(node: CreateViewNode): void
282-
protected abstract visitRefreshMaterializedView(node: RefreshMaterializedViewNode): void
282+
protected abstract visitRefreshMaterializedView(
283+
node: RefreshMaterializedViewNode,
284+
): void
283285
protected abstract visitDropView(node: DropViewNode): void
284286
protected abstract visitGenerated(node: GeneratedNode): void
285287
protected abstract visitDefaultValue(node: DefaultValueNode): void

src/query-builder/aggregate-function-builder.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { freeze } from '../util/object-utils.js'
22
import { AggregateFunctionNode } from '../operation-node/aggregate-function-node.js'
33
import { AliasNode } from '../operation-node/alias-node.js'
44
import { IdentifierNode } from '../operation-node/identifier-node.js'
5-
import { preventAwait } from '../util/prevent-await.js'
65
import { OverBuilder } from './over-builder.js'
76
import { createOverBuilder } from '../parser/parse-utils.js'
87
import {
@@ -344,11 +343,6 @@ export class AggregateFunctionBuilder<DB, TB extends keyof DB, O = unknown>
344343
}
345344
}
346345

347-
preventAwait(
348-
AggregateFunctionBuilder,
349-
"don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.",
350-
)
351-
352346
/**
353347
* {@link AggregateFunctionBuilder} with an alias. The result of calling {@link AggregateFunctionBuilder.as}.
354348
*/

src/query-builder/cte-builder.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { OperationNodeSource } from '../operation-node/operation-node-source.js'
22
import { CommonTableExpressionNode } from '../operation-node/common-table-expression-node.js'
3-
import { preventAwait } from '../util/prevent-await.js'
43
import { freeze } from '../util/object-utils.js'
54

65
export class CTEBuilder<N extends string> implements OperationNodeSource {
@@ -39,11 +38,6 @@ export class CTEBuilder<N extends string> implements OperationNodeSource {
3938
}
4039
}
4140

42-
preventAwait(
43-
CTEBuilder,
44-
"don't await CTEBuilder instances. They are never executed directly and are always just a part of a query.",
45-
)
46-
4741
interface CTEBuilderProps {
4842
readonly node: CommonTableExpressionNode
4943
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import {
3535
SimplifySingleResult,
3636
SqlBool,
3737
} from '../util/type-utils.js'
38-
import { preventAwait } from '../util/prevent-await.js'
3938
import { Compilable } from '../util/compilable.js'
4039
import { QueryExecutor } from '../query-executor/query-executor.js'
4140
import { QueryId } from '../util/query-id.js'
@@ -1153,11 +1152,6 @@ export class DeleteQueryBuilder<DB, TB extends keyof DB, O>
11531152
}
11541153
}
11551154

1156-
preventAwait(
1157-
DeleteQueryBuilder,
1158-
"don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.",
1159-
)
1160-
11611155
export interface DeleteQueryBuilderProps {
11621156
readonly queryId: QueryId
11631157
readonly queryNode: DeleteQueryNode

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
UpdateObjectExpression,
2323
parseUpdateObjectExpression,
2424
} from '../parser/update-set-parser.js'
25-
import { preventAwait } from '../util/prevent-await.js'
2625
import { Compilable } from '../util/compilable.js'
2726
import { QueryExecutor } from '../query-executor/query-executor.js'
2827
import { QueryId } from '../util/query-id.js'
@@ -1076,11 +1075,6 @@ export class InsertQueryBuilder<DB, TB extends keyof DB, O>
10761075
}
10771076
}
10781077

1079-
preventAwait(
1080-
InsertQueryBuilder,
1081-
"don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.",
1082-
)
1083-
10841078
export interface InsertQueryBuilderProps {
10851079
readonly queryId: QueryId
10861080
readonly queryNode: InsertQueryNode

src/query-builder/join-builder.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
import { ExpressionOrFactory } from '../parser/expression-parser.js'
1111
import { ReferenceExpression } from '../parser/reference-parser.js'
1212
import { freeze } from '../util/object-utils.js'
13-
import { preventAwait } from '../util/prevent-await.js'
1413
import { SqlBool } from '../util/type-utils.js'
1514

1615
export class JoinBuilder<DB, TB extends keyof DB>
@@ -92,11 +91,6 @@ export class JoinBuilder<DB, TB extends keyof DB>
9291
}
9392
}
9493

95-
preventAwait(
96-
JoinBuilder,
97-
"don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.",
98-
)
99-
10094
export interface JoinBuilderProps {
10195
readonly joinNode: JoinNode
10296
}

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import { NOOP_QUERY_EXECUTOR } from '../query-executor/noop-query-executor.js'
3737
import { QueryExecutor } from '../query-executor/query-executor.js'
3838
import { Compilable } from '../util/compilable.js'
3939
import { freeze } from '../util/object-utils.js'
40-
import { preventAwait } from '../util/prevent-await.js'
4140
import { QueryId } from '../util/query-id.js'
4241
import {
4342
ShallowRecord,
@@ -262,11 +261,6 @@ export class MergeQueryBuilder<DB, TT extends keyof DB, O>
262261
}
263262
}
264263

265-
preventAwait(
266-
MergeQueryBuilder,
267-
"don't await MergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.",
268-
)
269-
270264
export interface MergeQueryBuilderProps {
271265
readonly queryId: QueryId
272266
readonly queryNode: MergeQueryNode
@@ -833,11 +827,6 @@ export class WheneableMergeQueryBuilder<
833827
}
834828
}
835829

836-
preventAwait(
837-
WheneableMergeQueryBuilder,
838-
"don't await WheneableMergeQueryBuilder instances directly. To execute the query you need to call `execute`.",
839-
)
840-
841830
export class MatchedThenableMergeQueryBuilder<
842831
DB,
843832
TT extends keyof DB,
@@ -1034,11 +1023,6 @@ export class MatchedThenableMergeQueryBuilder<
10341023
}
10351024
}
10361025

1037-
preventAwait(
1038-
MatchedThenableMergeQueryBuilder,
1039-
"don't await MatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.",
1040-
)
1041-
10421026
export class NotMatchedThenableMergeQueryBuilder<
10431027
DB,
10441028
TT extends keyof DB,
@@ -1145,11 +1129,6 @@ export class NotMatchedThenableMergeQueryBuilder<
11451129
}
11461130
}
11471131

1148-
preventAwait(
1149-
NotMatchedThenableMergeQueryBuilder,
1150-
"don't await NotMatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.",
1151-
)
1152-
11531132
export type ExtractWheneableMergeQueryBuilder<
11541133
DB,
11551134
TT extends keyof DB,

src/query-builder/on-conflict-builder.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
} from '../parser/update-set-parser.js'
1818
import { Updateable } from '../util/column-type.js'
1919
import { freeze } from '../util/object-utils.js'
20-
import { preventAwait } from '../util/prevent-await.js'
2120
import { AnyColumn, SqlBool } from '../util/type-utils.js'
2221
import { WhereInterface } from './where-interface.js'
2322

@@ -251,8 +250,6 @@ export interface OnConflictBuilderProps {
251250
readonly onConflictNode: OnConflictNode
252251
}
253252

254-
preventAwait(OnConflictBuilder, "don't await OnConflictBuilder instances.")
255-
256253
export type OnConflictDatabase<DB, TB extends keyof DB> = {
257254
[K in keyof DB | 'excluded']: Updateable<K extends keyof DB ? DB[K] : DB[TB]>
258255
}
@@ -273,11 +270,6 @@ export class OnConflictDoNothingBuilder<DB, TB extends keyof DB>
273270
}
274271
}
275272

276-
preventAwait(
277-
OnConflictDoNothingBuilder,
278-
"don't await OnConflictDoNothingBuilder instances.",
279-
)
280-
281273
export class OnConflictUpdateBuilder<DB, TB extends keyof DB>
282274
implements WhereInterface<DB, TB>, OperationNodeSource
283275
{
@@ -358,8 +350,3 @@ export class OnConflictUpdateBuilder<DB, TB extends keyof DB>
358350
return this.#props.onConflictNode
359351
}
360352
}
361-
362-
preventAwait(
363-
OnConflictUpdateBuilder,
364-
"don't await OnConflictUpdateBuilder instances.",
365-
)

0 commit comments

Comments
 (0)