(db: Kysely<any>)
| 7 | import { expectType } from 'tsd' |
| 8 | |
| 9 | async function testKyselyAnySelects(db: Kysely<any>) { |
| 10 | const r1 = await db.selectFrom('foo').select('bar').execute() |
| 11 | expectType<{ bar: any }[]>(r1) |
| 12 | |
| 13 | const r2 = await db.selectFrom('foo').select(['bar', 'baz']).execute() |
| 14 | expectType<{ bar: any; baz: any }[]>(r2) |
| 15 | |
| 16 | const r3 = await db.selectFrom('foo').select('foo.bar').execute() |
| 17 | expectType<{ bar: any }[]>(r3) |
| 18 | |
| 19 | const r4 = await db |
| 20 | .selectFrom('foo') |
| 21 | .select(['spam', 'foo.bar', 'foo.baz']) |
| 22 | .execute() |
| 23 | expectType<{ spam: any; bar: any; baz: any }[]>(r4) |
| 24 | |
| 25 | const r5 = await db |
| 26 | .selectFrom(['foo1', 'foo2']) |
| 27 | .select(['spam', 'foo1.bar', 'foo2.baz', 'doesnotexists.fux']) |
| 28 | .execute() |
| 29 | expectType<{ spam: any; bar: any; baz: any; fux: any }[]>(r5) |
| 30 | |
| 31 | const r6 = await db |
| 32 | .selectFrom('foo') |
| 33 | .select((eb) => [ |
| 34 | eb.lit(1).as('baz'), |
| 35 | eb.ref('foo.bar').as('bar'), |
| 36 | eb |
| 37 | .selectFrom('bar') |
| 38 | .select('spam') |
| 39 | .whereRef('foo.id', '=', 'bar.id') |
| 40 | .as('spam'), |
| 41 | ]) |
| 42 | .executeTakeFirstOrThrow() |
| 43 | expectType<{ bar: any; spam: any; baz: 1 }>(r6) |
| 44 | |
| 45 | const table: 'foo' | 'bar' = Math.random() > 0.5 ? 'foo' : 'bar' |
| 46 | const r7 = await db.selectFrom(table).select('baz').executeTakeFirstOrThrow() |
| 47 | expectType<{ baz: any }>(r7) |
| 48 | |
| 49 | const r8 = await db.selectFrom('foo as f').select('bar').execute() |
| 50 | expectType<{ bar: any }[]>(r8) |
| 51 | |
| 52 | const r9 = await db |
| 53 | .selectFrom(['foo1 as f1', 'foo2 as f2']) |
| 54 | .select(['spam', 'f1.bar', 'f2.baz', 'doesnotexists.fux']) |
| 55 | .execute() |
| 56 | expectType<{ spam: any; bar: any; baz: any; fux: any }[]>(r9) |
| 57 | } |
| 58 | |
| 59 | async function testKyselyAnyInserts(db: Kysely<any>) { |
| 60 | const r1 = await db |
nothing calls this directly
no test coverage detected
searching dependent graphs…