Skip to content

Commit

Permalink
fixes #1039
Browse files Browse the repository at this point in the history
  • Loading branch information
koskimas committed Jun 13, 2024
1 parent 9519ffd commit 873671b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/query-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class QueryCreator<DB> {
from: TE[],
): SelectQueryBuilder<DB, ExtractTableAlias<DB, TE>, {}>

selectFrom<TE extends TableExpression<DB, keyof DB>>(
selectFrom<TE extends TableExpression<DB, never>>(
from: TE[],
): SelectQueryBuilder<From<DB, TE>, FromTables<DB, never, TE>, {}>

Expand All @@ -187,7 +187,7 @@ export class QueryCreator<DB> {
{}
>

selectFrom<TE extends TableExpression<DB, keyof DB>>(
selectFrom<TE extends TableExpression<DB, never>>(
from: TE,
): SelectQueryBuilder<From<DB, TE>, FromTables<DB, never, TE>, {}>

Expand Down
10 changes: 10 additions & 0 deletions test/typings/test-d/select-from.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ async function testFromSingle(db: Kysely<Database>) {
.execute()
expectType<{ strs: number }>(r4)

// Subquery factory list
const [r4_2] = await db
.selectFrom([
(eb) => eb.selectFrom('movie').select('movie.stars as strs').as('m'),
(eb) => eb.selectFrom('pet').select('id').as('p'),
])
.selectAll(['m', 'p'])
.execute()
expectType<{ strs: number; id: string }>(r4_2)

// Table with schema
const [r5] = await db
.selectFrom('some_schema.movie')
Expand Down

0 comments on commit 873671b

Please sign in to comment.