Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
igalklebanov committed Aug 4, 2024
1 parent a141f7d commit 70bc7c8
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions test/typings/test-d/select.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import {
NotNull,
RawBuilder,
Selectable,
SelectType,
Simplify,
sql,
} from '..'
import { Database, Person } from '../shared'
import { expectType, expectError } from 'tsd'
import { Database, Person, Pet } from '../shared'
import {
expectType,
expectError,
expectAssignable,
expectNotAssignable,
} from 'tsd'

async function testSelectSingle(db: Kysely<Database>) {
const qb = db.selectFrom('person')
Expand Down Expand Up @@ -206,6 +212,26 @@ async function testSelectAll(db: Kysely<Database>) {
species: 'dog' | 'cat'
deleted_at: Date | null
}>(r5)

const r6 = await db
.selectFrom('person')
.leftJoin('pet', 'person.id', 'pet.owner_id')
.selectAll('person')
.selectAll('pet')
.executeTakeFirstOrThrow()

expectAssignable<{ id: string | null }>(r6)
expectNotAssignable<{ id: number }>(r6)

const r7 = await db
.selectFrom('person')
.leftJoin('pet', 'person.id', 'pet.owner_id')
.selectAll('pet')
.selectAll('person')
.executeTakeFirstOrThrow()

expectAssignable<{ id: number }>(r7)
expectNotAssignable<{ id: string | null }>(r7)
}

async function testSelectMultiple(db: Kysely<Database>) {
Expand Down

0 comments on commit 70bc7c8

Please sign in to comment.