Skip to content

Commit

Permalink
fix InferResult not working for merge queries. (#902)
Browse files Browse the repository at this point in the history
  • Loading branch information
igalklebanov authored Jun 27, 2024
1 parent 0dd0978 commit f353fc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/query-builder/merge-query-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ export class WheneableMergeQueryBuilder<
)
}

compile(): CompiledQuery<never> {
compile(): CompiledQuery<O> {
return this.#props.executor.compileQuery(
this.toOperationNode(),
this.#props.queryId,
Expand Down
14 changes: 14 additions & 0 deletions test/typings/test-d/infer-result.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
InferResult,
InsertResult,
Kysely,
MergeResult,
Selectable,
UpdateResult,
} from '..'
Expand Down Expand Up @@ -128,3 +129,16 @@ function testInferResultDeleteQuery(db: Kysely<Database>) {
expectType<Equals<Expected2, InferResult<typeof query2>>>(true)
expectType<Equals<Expected2, InferResult<typeof compiledQuery2>>>(true)
}

function testInferResultMergeQuery(db: Kysely<Database>) {
const query0 = db
.mergeInto('person')
.using('pet', 'pet.owner_id', 'person.id')
.whenMatched()
.thenDelete()
const compiledQuery0 = query0.compile()

type Expected0 = MergeResult
expectType<Equals<Expected0, InferResult<typeof query0>>>(true)
expectType<Equals<Expected0, InferResult<typeof compiledQuery0>>>(true)
}

0 comments on commit f353fc6

Please sign in to comment.