diff --git a/src/kysely.ts b/src/kysely.ts index cf3405077..dadffe8da 100644 --- a/src/kysely.ts +++ b/src/kysely.ts @@ -16,7 +16,6 @@ import { TransactionSettings, TRANSACTION_ISOLATION_LEVELS, } from './driver/driver.js' -import { preventAwait } from './util/prevent-await.js' import { createFunctionModule, FunctionModule, @@ -526,11 +525,6 @@ export class ConnectionBuilder { interface ConnectionBuilderProps extends KyselyProps {} -preventAwait( - ConnectionBuilder, - "don't await ConnectionBuilder instances directly. To execute the query you need to call the `execute` method", -) - export class TransactionBuilder { readonly #props: TransactionBuilderProps @@ -579,11 +573,6 @@ interface TransactionBuilderProps extends KyselyProps { readonly isolationLevel?: IsolationLevel } -preventAwait( - TransactionBuilder, - "don't await TransactionBuilder instances directly. To execute the transaction you need to call the `execute` method", -) - function validateTransactionSettings(settings: TransactionSettings): void { if ( settings.isolationLevel && diff --git a/src/operation-node/operation-node-transformer.ts b/src/operation-node/operation-node-transformer.ts index a9bca4d5e..246846be6 100644 --- a/src/operation-node/operation-node-transformer.ts +++ b/src/operation-node/operation-node-transformer.ts @@ -190,7 +190,8 @@ export class OperationNodeTransformer { DropConstraintNode: this.transformDropConstraint.bind(this), ForeignKeyConstraintNode: this.transformForeignKeyConstraint.bind(this), CreateViewNode: this.transformCreateView.bind(this), - RefreshMaterializedViewNode: this.transformRefreshMaterializedView.bind(this), + RefreshMaterializedViewNode: + this.transformRefreshMaterializedView.bind(this), DropViewNode: this.transformDropView.bind(this), GeneratedNode: this.transformGenerated.bind(this), DefaultValueNode: this.transformDefaultValue.bind(this), @@ -798,7 +799,9 @@ export class OperationNodeTransformer { }) } - protected transformRefreshMaterializedView(node: RefreshMaterializedViewNode): RefreshMaterializedViewNode { + protected transformRefreshMaterializedView( + node: RefreshMaterializedViewNode, + ): RefreshMaterializedViewNode { return requireAllProps({ kind: 'RefreshMaterializedViewNode', name: this.transformNode(node.name), diff --git a/src/operation-node/operation-node-visitor.ts b/src/operation-node/operation-node-visitor.ts index bbe02da53..533f58098 100644 --- a/src/operation-node/operation-node-visitor.ts +++ b/src/operation-node/operation-node-visitor.ts @@ -279,7 +279,9 @@ export abstract class OperationNodeVisitor { protected abstract visitPrimitiveValueList(node: PrimitiveValueListNode): void protected abstract visitOperator(node: OperatorNode): void protected abstract visitCreateView(node: CreateViewNode): void - protected abstract visitRefreshMaterializedView(node: RefreshMaterializedViewNode): void + protected abstract visitRefreshMaterializedView( + node: RefreshMaterializedViewNode, + ): void protected abstract visitDropView(node: DropViewNode): void protected abstract visitGenerated(node: GeneratedNode): void protected abstract visitDefaultValue(node: DefaultValueNode): void diff --git a/src/query-builder/aggregate-function-builder.ts b/src/query-builder/aggregate-function-builder.ts index ebd559fbf..0b1f93095 100644 --- a/src/query-builder/aggregate-function-builder.ts +++ b/src/query-builder/aggregate-function-builder.ts @@ -2,7 +2,6 @@ import { freeze } from '../util/object-utils.js' import { AggregateFunctionNode } from '../operation-node/aggregate-function-node.js' import { AliasNode } from '../operation-node/alias-node.js' import { IdentifierNode } from '../operation-node/identifier-node.js' -import { preventAwait } from '../util/prevent-await.js' import { OverBuilder } from './over-builder.js' import { createOverBuilder } from '../parser/parse-utils.js' import { @@ -344,11 +343,6 @@ export class AggregateFunctionBuilder } } -preventAwait( - AggregateFunctionBuilder, - "don't await AggregateFunctionBuilder instances. They are never executed directly and are always just a part of a query.", -) - /** * {@link AggregateFunctionBuilder} with an alias. The result of calling {@link AggregateFunctionBuilder.as}. */ diff --git a/src/query-builder/cte-builder.ts b/src/query-builder/cte-builder.ts index b1d6013c3..7e0591640 100644 --- a/src/query-builder/cte-builder.ts +++ b/src/query-builder/cte-builder.ts @@ -1,6 +1,5 @@ import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CommonTableExpressionNode } from '../operation-node/common-table-expression-node.js' -import { preventAwait } from '../util/prevent-await.js' import { freeze } from '../util/object-utils.js' export class CTEBuilder implements OperationNodeSource { @@ -39,11 +38,6 @@ export class CTEBuilder implements OperationNodeSource { } } -preventAwait( - CTEBuilder, - "don't await CTEBuilder instances. They are never executed directly and are always just a part of a query.", -) - interface CTEBuilderProps { readonly node: CommonTableExpressionNode } diff --git a/src/query-builder/delete-query-builder.ts b/src/query-builder/delete-query-builder.ts index 3e3de6a77..77306c03f 100644 --- a/src/query-builder/delete-query-builder.ts +++ b/src/query-builder/delete-query-builder.ts @@ -35,7 +35,6 @@ import { SimplifySingleResult, SqlBool, } from '../util/type-utils.js' -import { preventAwait } from '../util/prevent-await.js' import { Compilable } from '../util/compilable.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' @@ -1153,11 +1152,6 @@ export class DeleteQueryBuilder } } -preventAwait( - DeleteQueryBuilder, - "don't await DeleteQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.", -) - export interface DeleteQueryBuilderProps { readonly queryId: QueryId readonly queryNode: DeleteQueryNode diff --git a/src/query-builder/insert-query-builder.ts b/src/query-builder/insert-query-builder.ts index 21a850bab..75fa39dfc 100644 --- a/src/query-builder/insert-query-builder.ts +++ b/src/query-builder/insert-query-builder.ts @@ -22,7 +22,6 @@ import { UpdateObjectExpression, parseUpdateObjectExpression, } from '../parser/update-set-parser.js' -import { preventAwait } from '../util/prevent-await.js' import { Compilable } from '../util/compilable.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' @@ -1076,11 +1075,6 @@ export class InsertQueryBuilder } } -preventAwait( - InsertQueryBuilder, - "don't await InsertQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.", -) - export interface InsertQueryBuilderProps { readonly queryId: QueryId readonly queryNode: InsertQueryNode diff --git a/src/query-builder/join-builder.ts b/src/query-builder/join-builder.ts index 9866faa67..da2163877 100644 --- a/src/query-builder/join-builder.ts +++ b/src/query-builder/join-builder.ts @@ -10,7 +10,6 @@ import { import { ExpressionOrFactory } from '../parser/expression-parser.js' import { ReferenceExpression } from '../parser/reference-parser.js' import { freeze } from '../util/object-utils.js' -import { preventAwait } from '../util/prevent-await.js' import { SqlBool } from '../util/type-utils.js' export class JoinBuilder @@ -92,11 +91,6 @@ export class JoinBuilder } } -preventAwait( - JoinBuilder, - "don't await JoinBuilder instances. They are never executed directly and are always just a part of a query.", -) - export interface JoinBuilderProps { readonly joinNode: JoinNode } diff --git a/src/query-builder/merge-query-builder.ts b/src/query-builder/merge-query-builder.ts index 8bb9881a7..8bab1b6c6 100644 --- a/src/query-builder/merge-query-builder.ts +++ b/src/query-builder/merge-query-builder.ts @@ -37,7 +37,6 @@ import { NOOP_QUERY_EXECUTOR } from '../query-executor/noop-query-executor.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { Compilable } from '../util/compilable.js' import { freeze } from '../util/object-utils.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryId } from '../util/query-id.js' import { ShallowRecord, @@ -262,11 +261,6 @@ export class MergeQueryBuilder } } -preventAwait( - MergeQueryBuilder, - "don't await MergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.", -) - export interface MergeQueryBuilderProps { readonly queryId: QueryId readonly queryNode: MergeQueryNode @@ -833,11 +827,6 @@ export class WheneableMergeQueryBuilder< } } -preventAwait( - WheneableMergeQueryBuilder, - "don't await WheneableMergeQueryBuilder instances directly. To execute the query you need to call `execute`.", -) - export class MatchedThenableMergeQueryBuilder< DB, TT extends keyof DB, @@ -1034,11 +1023,6 @@ export class MatchedThenableMergeQueryBuilder< } } -preventAwait( - MatchedThenableMergeQueryBuilder, - "don't await MatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.", -) - export class NotMatchedThenableMergeQueryBuilder< DB, TT extends keyof DB, @@ -1145,11 +1129,6 @@ export class NotMatchedThenableMergeQueryBuilder< } } -preventAwait( - NotMatchedThenableMergeQueryBuilder, - "don't await NotMatchedThenableMergeQueryBuilder instances directly. To execute the query you need to call `execute` when available.", -) - export type ExtractWheneableMergeQueryBuilder< DB, TT extends keyof DB, diff --git a/src/query-builder/on-conflict-builder.ts b/src/query-builder/on-conflict-builder.ts index cfdfaeda8..8f6dc7b3d 100644 --- a/src/query-builder/on-conflict-builder.ts +++ b/src/query-builder/on-conflict-builder.ts @@ -17,7 +17,6 @@ import { } from '../parser/update-set-parser.js' import { Updateable } from '../util/column-type.js' import { freeze } from '../util/object-utils.js' -import { preventAwait } from '../util/prevent-await.js' import { AnyColumn, SqlBool } from '../util/type-utils.js' import { WhereInterface } from './where-interface.js' @@ -251,8 +250,6 @@ export interface OnConflictBuilderProps { readonly onConflictNode: OnConflictNode } -preventAwait(OnConflictBuilder, "don't await OnConflictBuilder instances.") - export type OnConflictDatabase = { [K in keyof DB | 'excluded']: Updateable } @@ -273,11 +270,6 @@ export class OnConflictDoNothingBuilder } } -preventAwait( - OnConflictDoNothingBuilder, - "don't await OnConflictDoNothingBuilder instances.", -) - export class OnConflictUpdateBuilder implements WhereInterface, OperationNodeSource { @@ -358,8 +350,3 @@ export class OnConflictUpdateBuilder return this.#props.onConflictNode } } - -preventAwait( - OnConflictUpdateBuilder, - "don't await OnConflictUpdateBuilder instances.", -) diff --git a/src/query-builder/over-builder.ts b/src/query-builder/over-builder.ts index 330be843a..675f4950c 100644 --- a/src/query-builder/over-builder.ts +++ b/src/query-builder/over-builder.ts @@ -12,7 +12,6 @@ import { } from '../parser/partition-by-parser.js' import { StringReference } from '../parser/reference-parser.js' import { freeze } from '../util/object-utils.js' -import { preventAwait } from '../util/prevent-await.js' export class OverBuilder implements OperationNodeSource @@ -107,11 +106,6 @@ export class OverBuilder } } -preventAwait( - OverBuilder, - "don't await OverBuilder instances. They are never executed directly and are always just a part of a query.", -) - export interface OverBuilderProps { readonly overNode: OverNode } diff --git a/src/query-builder/select-query-builder.ts b/src/query-builder/select-query-builder.ts index 9c0156810..b5a2a89be 100644 --- a/src/query-builder/select-query-builder.ts +++ b/src/query-builder/select-query-builder.ts @@ -40,7 +40,6 @@ import { UndirectedOrderByExpression, parseOrderBy, } from '../parser/order-by-parser.js' -import { preventAwait } from '../util/prevent-await.js' import { LimitNode } from '../operation-node/limit-node.js' import { OffsetNode } from '../operation-node/offset-node.js' import { Compilable } from '../util/compilable.js' @@ -2487,11 +2486,6 @@ class SelectQueryBuilderImpl } } -preventAwait( - SelectQueryBuilderImpl, - "don't await SelectQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.", -) - export function createSelectQueryBuilder( props: SelectQueryBuilderProps, ): SelectQueryBuilder { @@ -2549,11 +2543,6 @@ class AliasedSelectQueryBuilderImpl< } } -preventAwait( - AliasedSelectQueryBuilderImpl, - "don't await AliasedSelectQueryBuilder instances directly. AliasedSelectQueryBuilder should never be executed directly since it's always a part of another query.", -) - export type SelectQueryBuilderWithInnerJoin< DB, TB extends keyof DB, diff --git a/src/query-builder/update-query-builder.ts b/src/query-builder/update-query-builder.ts index bf0605a66..b0f549ddf 100644 --- a/src/query-builder/update-query-builder.ts +++ b/src/query-builder/update-query-builder.ts @@ -41,7 +41,6 @@ import { ExtractUpdateTypeFromReferenceExpression, parseUpdate, } from '../parser/update-set-parser.js' -import { preventAwait } from '../util/prevent-await.js' import { Compilable } from '../util/compilable.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' @@ -1151,11 +1150,6 @@ export class UpdateQueryBuilder } } -preventAwait( - UpdateQueryBuilder, - "don't await UpdateQueryBuilder instances directly. To execute the query you need to call `execute` or `executeTakeFirst`.", -) - export interface UpdateQueryBuilderProps { readonly queryId: QueryId readonly queryNode: UpdateQueryNode diff --git a/src/query-compiler/default-query-compiler.ts b/src/query-compiler/default-query-compiler.ts index f2c4e2379..5a04313d6 100644 --- a/src/query-compiler/default-query-compiler.ts +++ b/src/query-compiler/default-query-compiler.ts @@ -810,7 +810,9 @@ export class DefaultQueryCompiler if (node.joins) { if (!node.from) { - throw new Error("Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins") + throw new Error( + "Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins", + ) } this.append(' ') @@ -1254,8 +1256,10 @@ export class DefaultQueryCompiler this.visitNode(node.as) } } - - protected override visitRefreshMaterializedView(node: RefreshMaterializedViewNode): void { + + protected override visitRefreshMaterializedView( + node: RefreshMaterializedViewNode, + ): void { this.append('refresh materialized view ') if (node.concurrently) { diff --git a/src/raw-builder/raw-builder.ts b/src/raw-builder/raw-builder.ts index aeb73467d..895044d61 100644 --- a/src/raw-builder/raw-builder.ts +++ b/src/raw-builder/raw-builder.ts @@ -2,7 +2,6 @@ import { QueryResult } from '../driver/database-connection.js' import { AliasNode } from '../operation-node/alias-node.js' import { RawNode } from '../operation-node/raw-node.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { freeze } from '../util/object-utils.js' import { KyselyPlugin } from '../plugin/kysely-plugin.js' @@ -221,11 +220,6 @@ export function createRawBuilder(props: RawBuilderProps): RawBuilder { return new RawBuilderImpl(props) } -preventAwait( - RawBuilderImpl, - "don't await RawBuilder instances directly. To execute the query you need to call `execute`", -) - /** * {@link RawBuilder} with an alias. The result of calling {@link RawBuilder.as}. */ @@ -266,8 +260,3 @@ class AliasedRawBuilderImpl ) } } - -preventAwait( - AliasedRawBuilderImpl, - "don't await AliasedRawBuilder instances directly. AliasedRawBuilder should never be executed directly since it's always a part of another query.", -) diff --git a/src/schema/alter-column-builder.ts b/src/schema/alter-column-builder.ts index 61cf708cd..caa41b04d 100644 --- a/src/schema/alter-column-builder.ts +++ b/src/schema/alter-column-builder.ts @@ -8,7 +8,6 @@ import { DefaultValueExpression, parseDefaultValueExpression, } from '../parser/default-value-parser.js' -import { preventAwait } from '../util/prevent-await.js' export class AlterColumnBuilder { readonly #column: string @@ -64,8 +63,6 @@ export class AlterColumnBuilder { } } -preventAwait(AlterColumnBuilder, "don't await AlterColumnBuilder instances") - /** * Allows us to force consumers to do exactly one alteration to a column. * @@ -96,5 +93,3 @@ export class AlteredColumnBuilder implements OperationNodeSource { export type AlterColumnBuilderCallback = ( builder: AlterColumnBuilder, ) => AlteredColumnBuilder - -preventAwait(AlteredColumnBuilder, "don't await AlteredColumnBuilder instances") diff --git a/src/schema/alter-table-add-foreign-key-constraint-builder.ts b/src/schema/alter-table-add-foreign-key-constraint-builder.ts index 4bdc3165d..046efa3af 100644 --- a/src/schema/alter-table-add-foreign-key-constraint-builder.ts +++ b/src/schema/alter-table-add-foreign-key-constraint-builder.ts @@ -6,7 +6,6 @@ import { CompiledQuery } from '../query-compiler/compiled-query.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { Compilable } from '../util/compilable.js' import { freeze } from '../util/object-utils.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryId } from '../util/query-id.js' import { ForeignKeyConstraintBuilder, @@ -80,8 +79,3 @@ export interface AlterTableAddForeignKeyConstraintBuilderProps { readonly node: AlterTableNode readonly constraintBuilder: ForeignKeyConstraintBuilder } - -preventAwait( - AlterTableAddForeignKeyConstraintBuilder, - "don't await AlterTableAddForeignKeyConstraintBuilder instances directly. To execute the query you need to call `execute`", -) diff --git a/src/schema/alter-table-add-index-builder.ts b/src/schema/alter-table-add-index-builder.ts index 6110883a0..5e877eb7d 100644 --- a/src/schema/alter-table-add-index-builder.ts +++ b/src/schema/alter-table-add-index-builder.ts @@ -12,7 +12,6 @@ import { CompiledQuery } from '../query-compiler/compiled-query.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { Compilable } from '../util/compilable.js' import { freeze } from '../util/object-utils.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryId } from '../util/query-id.js' export class AlterTableAddIndexBuilder @@ -190,8 +189,3 @@ export interface AlterTableAddIndexBuilderProps { readonly executor: QueryExecutor readonly node: AlterTableNode } - -preventAwait( - AlterTableAddIndexBuilder, - "don't await AlterTableAddIndexBuilder instances directly. To execute the query you need to call `execute`", -) diff --git a/src/schema/alter-table-builder.ts b/src/schema/alter-table-builder.ts index b7bee0308..034d144be 100644 --- a/src/schema/alter-table-builder.ts +++ b/src/schema/alter-table-builder.ts @@ -8,7 +8,6 @@ import { RenameColumnNode } from '../operation-node/rename-column-node.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' import { freeze, noop } from '../util/object-utils.js' -import { preventAwait } from '../util/prevent-await.js' import { ColumnDefinitionBuilder, ColumnDefinitionBuilderCallback, @@ -323,8 +322,6 @@ export interface AlterTableBuilderProps { readonly node: AlterTableNode } -preventAwait(AlterTableBuilder, "don't await AlterTableBuilder instances") - export interface ColumnAlteringInterface { alterColumn( column: string, @@ -470,8 +467,3 @@ export class AlterTableColumnAlteringBuilder export interface AlterTableColumnAlteringBuilderProps extends AlterTableBuilderProps {} - -preventAwait( - AlterTableColumnAlteringBuilder, - "don't await AlterTableColumnAlteringBuilder instances directly. To execute the query you need to call `execute`", -) diff --git a/src/schema/alter-table-drop-constraint-builder.ts b/src/schema/alter-table-drop-constraint-builder.ts index e6b4199be..4e3ec4117 100644 --- a/src/schema/alter-table-drop-constraint-builder.ts +++ b/src/schema/alter-table-drop-constraint-builder.ts @@ -5,7 +5,6 @@ import { CompiledQuery } from '../query-compiler/compiled-query.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { Compilable } from '../util/compilable.js' import { freeze } from '../util/object-utils.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryId } from '../util/query-id.js' export class AlterTableDropConstraintBuilder @@ -91,8 +90,3 @@ export interface AlterTableDropConstraintBuilderProps { readonly executor: QueryExecutor readonly node: AlterTableNode } - -preventAwait( - AlterTableDropConstraintBuilder, - "don't await AlterTableDropConstraintBuilder instances directly. To execute the query you need to call `execute`", -) diff --git a/src/schema/alter-table-executor.ts b/src/schema/alter-table-executor.ts index 08a172eb3..692d447c4 100644 --- a/src/schema/alter-table-executor.ts +++ b/src/schema/alter-table-executor.ts @@ -4,7 +4,6 @@ import { CompiledQuery } from '../query-compiler/compiled-query.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { Compilable } from '../util/compilable.js' import { freeze } from '../util/object-utils.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryId } from '../util/query-id.js' export class AlterTableExecutor implements OperationNodeSource, Compilable { @@ -38,8 +37,3 @@ export interface AlterTableExecutorProps { readonly executor: QueryExecutor readonly node: AlterTableNode } - -preventAwait( - AlterTableExecutor, - "don't await AlterTableExecutor instances directly. To execute the query you need to call `execute`", -) diff --git a/src/schema/column-definition-builder.ts b/src/schema/column-definition-builder.ts index 817c07ee9..8dba9f17b 100644 --- a/src/schema/column-definition-builder.ts +++ b/src/schema/column-definition-builder.ts @@ -6,7 +6,6 @@ import { } from '../operation-node/references-node.js' import { SelectAllNode } from '../operation-node/select-all-node.js' import { parseStringReference } from '../parser/reference-parser.js' -import { preventAwait } from '../util/prevent-await.js' import { ColumnDefinitionNode } from '../operation-node/column-definition-node.js' import { DefaultValueExpression, @@ -429,11 +428,6 @@ export class ColumnDefinitionBuilder implements OperationNodeSource { } } -preventAwait( - ColumnDefinitionBuilder, - "don't await ColumnDefinitionBuilder instances directly.", -) - export type ColumnDefinitionBuilderCallback = ( builder: ColumnDefinitionBuilder, ) => ColumnDefinitionBuilder diff --git a/src/schema/create-index-builder.ts b/src/schema/create-index-builder.ts index c2f6eca30..28b215c6f 100644 --- a/src/schema/create-index-builder.ts +++ b/src/schema/create-index-builder.ts @@ -12,7 +12,6 @@ import { import { parseTable } from '../parser/table-parser.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' import { freeze } from '../util/object-utils.js' @@ -303,11 +302,6 @@ export class CreateIndexBuilder } } -preventAwait( - CreateIndexBuilder, - "don't await CreateIndexBuilder instances directly. To execute the query you need to call `execute`", -) - export interface CreateIndexBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/create-schema-builder.ts b/src/schema/create-schema-builder.ts index dd5d6998e..071cdcc35 100644 --- a/src/schema/create-schema-builder.ts +++ b/src/schema/create-schema-builder.ts @@ -2,7 +2,6 @@ import { CreateSchemaNode } from '../operation-node/create-schema-node.js' import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' import { freeze } from '../util/object-utils.js' @@ -48,11 +47,6 @@ export class CreateSchemaBuilder implements OperationNodeSource, Compilable { } } -preventAwait( - CreateSchemaBuilder, - "don't await CreateSchemaBuilder instances directly. To execute the query you need to call `execute`", -) - export interface CreateSchemaBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/create-table-builder.ts b/src/schema/create-table-builder.ts index 9aefddaa1..a556037a6 100644 --- a/src/schema/create-table-builder.ts +++ b/src/schema/create-table-builder.ts @@ -6,7 +6,6 @@ import { import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { ColumnDefinitionBuilder } from './column-definition-builder.js' import { QueryId } from '../util/query-id.js' @@ -457,11 +456,6 @@ export class CreateTableBuilder } } -preventAwait( - CreateTableBuilder, - "don't await CreateTableBuilder instances directly. To execute the query you need to call `execute`", -) - export interface CreateTableBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/create-type-builder.ts b/src/schema/create-type-builder.ts index 78b9a3e6e..b9f079b4a 100644 --- a/src/schema/create-type-builder.ts +++ b/src/schema/create-type-builder.ts @@ -1,7 +1,6 @@ import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' import { freeze } from '../util/object-utils.js' @@ -57,11 +56,6 @@ export class CreateTypeBuilder implements OperationNodeSource, Compilable { } } -preventAwait( - CreateTypeBuilder, - "don't await CreateTypeBuilder instances directly. To execute the query you need to call `execute`", -) - export interface CreateTypeBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/create-view-builder.ts b/src/schema/create-view-builder.ts index 50ff2e428..2542c09f6 100644 --- a/src/schema/create-view-builder.ts +++ b/src/schema/create-view-builder.ts @@ -1,7 +1,6 @@ import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' import { freeze } from '../util/object-utils.js' @@ -122,11 +121,6 @@ export class CreateViewBuilder implements OperationNodeSource, Compilable { } } -preventAwait( - CreateViewBuilder, - "don't await CreateViewBuilder instances directly. To execute the query you need to call `execute`", -) - export interface CreateViewBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/drop-index-builder.ts b/src/schema/drop-index-builder.ts index 396b09ec9..4fabba208 100644 --- a/src/schema/drop-index-builder.ts +++ b/src/schema/drop-index-builder.ts @@ -2,7 +2,6 @@ import { DropIndexNode } from '../operation-node/drop-index-node.js' import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' import { parseTable } from '../parser/table-parser.js' @@ -73,11 +72,6 @@ export class DropIndexBuilder implements OperationNodeSource, Compilable { } } -preventAwait( - DropIndexBuilder, - "don't await DropIndexBuilder instances directly. To execute the query you need to call `execute`", -) - export interface DropIndexBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/drop-schema-builder.ts b/src/schema/drop-schema-builder.ts index fc248e219..98001f0c6 100644 --- a/src/schema/drop-schema-builder.ts +++ b/src/schema/drop-schema-builder.ts @@ -2,7 +2,6 @@ import { DropSchemaNode } from '../operation-node/drop-schema-node.js' import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' import { freeze } from '../util/object-utils.js' @@ -59,11 +58,6 @@ export class DropSchemaBuilder implements OperationNodeSource, Compilable { } } -preventAwait( - DropSchemaBuilder, - "don't await DropSchemaBuilder instances directly. To execute the query you need to call `execute`", -) - export interface DropSchemaBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/drop-table-builder.ts b/src/schema/drop-table-builder.ts index 120dece01..f5cf168e9 100644 --- a/src/schema/drop-table-builder.ts +++ b/src/schema/drop-table-builder.ts @@ -2,7 +2,6 @@ import { DropTableNode } from '../operation-node/drop-table-node.js' import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' import { freeze } from '../util/object-utils.js' @@ -59,11 +58,6 @@ export class DropTableBuilder implements OperationNodeSource, Compilable { } } -preventAwait( - DropTableBuilder, - "don't await DropTableBuilder instances directly. To execute the query you need to call `execute`", -) - export interface DropTableBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/drop-type-builder.ts b/src/schema/drop-type-builder.ts index e783c37f6..c94662069 100644 --- a/src/schema/drop-type-builder.ts +++ b/src/schema/drop-type-builder.ts @@ -2,7 +2,6 @@ import { DropTypeNode } from '../operation-node/drop-type-node.js' import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' import { freeze } from '../util/object-utils.js' @@ -50,11 +49,6 @@ export class DropTypeBuilder implements OperationNodeSource, Compilable { } } -preventAwait( - DropTypeBuilder, - "don't await DropTypeBuilder instances directly. To execute the query you need to call `execute`", -) - export interface DropTypeBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/drop-view-builder.ts b/src/schema/drop-view-builder.ts index 33634cad9..a7bd6e122 100644 --- a/src/schema/drop-view-builder.ts +++ b/src/schema/drop-view-builder.ts @@ -1,7 +1,6 @@ import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' import { freeze } from '../util/object-utils.js' @@ -68,11 +67,6 @@ export class DropViewBuilder implements OperationNodeSource, Compilable { } } -preventAwait( - DropViewBuilder, - "don't await DropViewBuilder instances directly. To execute the query you need to call `execute`", -) - export interface DropViewBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/foreign-key-constraint-builder.ts b/src/schema/foreign-key-constraint-builder.ts index 5a7e45fa5..56990cacf 100644 --- a/src/schema/foreign-key-constraint-builder.ts +++ b/src/schema/foreign-key-constraint-builder.ts @@ -2,7 +2,6 @@ import { ForeignKeyConstraintNode } from '../operation-node/foreign-key-constrai import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { OnModifyForeignAction } from '../operation-node/references-node.js' import { parseOnModifyForeignAction } from '../parser/on-modify-action-parser.js' -import { preventAwait } from '../util/prevent-await.js' export interface ForeignKeyConstraintBuilderInterface { onDelete(onDelete: OnModifyForeignAction): R @@ -48,8 +47,3 @@ export class ForeignKeyConstraintBuilder return this.#node } } - -preventAwait( - ForeignKeyConstraintBuilder, - "don't await ForeignKeyConstraintBuilder instances directly.", -) diff --git a/src/schema/refresh-materialized-view-builder.ts b/src/schema/refresh-materialized-view-builder.ts index 6691dd120..75787f1a7 100644 --- a/src/schema/refresh-materialized-view-builder.ts +++ b/src/schema/refresh-materialized-view-builder.ts @@ -1,13 +1,14 @@ import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { CompiledQuery } from '../query-compiler/compiled-query.js' import { Compilable } from '../util/compilable.js' -import { preventAwait } from '../util/prevent-await.js' import { QueryExecutor } from '../query-executor/query-executor.js' import { QueryId } from '../util/query-id.js' import { freeze } from '../util/object-utils.js' import { RefreshMaterializedViewNode } from '../operation-node/refresh-materialized-view-node.js' -export class RefreshMaterializedViewBuilder implements OperationNodeSource, Compilable { +export class RefreshMaterializedViewBuilder + implements OperationNodeSource, Compilable +{ readonly #props: RefreshMaterializedViewBuilderProps constructor(props: RefreshMaterializedViewBuilderProps) { @@ -16,9 +17,9 @@ export class RefreshMaterializedViewBuilder implements OperationNodeSource, Comp /** * Adds the "concurrently" modifier. - * + * * Use this to refresh the view without locking out concurrent selects on the materialized view. - * + * * WARNING! * This cannot be used with the "with no data" modifier. */ @@ -34,7 +35,7 @@ export class RefreshMaterializedViewBuilder implements OperationNodeSource, Comp /** * Adds the "with data" modifier. - * + * * If specified (or defaults) the backing query is executed to provide the new data, and the materialized view is left in a scannable state */ withData(): RefreshMaterializedViewBuilder { @@ -48,9 +49,9 @@ export class RefreshMaterializedViewBuilder implements OperationNodeSource, Comp /** * Adds the "with no data" modifier. - * + * * If specified, no new data is generated and the materialized view is left in an unscannable state. - * + * * WARNING! * This cannot be used with the "concurrently" modifier. */ @@ -91,11 +92,6 @@ export class RefreshMaterializedViewBuilder implements OperationNodeSource, Comp } } -preventAwait( - RefreshMaterializedViewBuilder, - "don't await RefreshMaterializedViewBuilder instances directly. To execute the query you need to call `execute`", -) - export interface RefreshMaterializedViewBuilderProps { readonly queryId: QueryId readonly executor: QueryExecutor diff --git a/src/schema/schema.ts b/src/schema/schema.ts index 1f8fe414d..07cbdeb4b 100644 --- a/src/schema/schema.ts +++ b/src/schema/schema.ts @@ -238,9 +238,9 @@ export class SchemaModule { /** * Refresh a materialized view. - * + * * ### Examples - * + * * ```ts * await db.schema * .refreshMaterializedView('my_view') diff --git a/src/schema/unique-constraint-builder.ts b/src/schema/unique-constraint-builder.ts index 324263098..4e1e0bcb1 100644 --- a/src/schema/unique-constraint-builder.ts +++ b/src/schema/unique-constraint-builder.ts @@ -1,6 +1,5 @@ import { OperationNodeSource } from '../operation-node/operation-node-source.js' import { UniqueConstraintNode } from '../operation-node/unique-constraint-node.js' -import { preventAwait } from '../util/prevent-await.js' export class UniqueConstraintNodeBuilder implements OperationNodeSource { readonly #node: UniqueConstraintNode @@ -25,11 +24,6 @@ export class UniqueConstraintNodeBuilder implements OperationNodeSource { } } -preventAwait( - UniqueConstraintNodeBuilder, - "don't await UniqueConstraintNodeBuilder instances directly.", -) - export type UniqueConstraintNodeBuilderCallback = ( builder: UniqueConstraintNodeBuilder, ) => UniqueConstraintNodeBuilder diff --git a/src/util/prevent-await.ts b/src/util/prevent-await.ts deleted file mode 100644 index 7a6089dda..000000000 --- a/src/util/prevent-await.ts +++ /dev/null @@ -1,10 +0,0 @@ -export function preventAwait(clazz: Function, message: string): void { - Object.defineProperties(clazz.prototype, { - then: { - enumerable: false, - value: () => { - throw new Error(message) - }, - }, - }) -} diff --git a/test/node/src/schema.test.ts b/test/node/src/schema.test.ts index 3816e4084..850f199de 100644 --- a/test/node/src/schema.test.ts +++ b/test/node/src/schema.test.ts @@ -1968,9 +1968,9 @@ for (const dialect of DIALECTS) { if (dialect === 'postgres') { it('should refresh a materialized view', async () => { - const builder = ctx.db.schema - .refreshMaterializedView('materialized_dogs') - + const builder = + ctx.db.schema.refreshMaterializedView('materialized_dogs') + testSql(builder, dialect, { postgres: { sql: `refresh materialized view "materialized_dogs" with data`,