MCPcopy
hub / github.com/kysely-org/kysely / testKyselyAnySelects

Function testKyselyAnySelects

test/typings/test-d/kysely-any.test-d.ts:9–57  ·  view source on GitHub ↗
(db: Kysely<any>)

Source from the content-addressed store, hash-verified

7import { expectType } from 'tsd'
8
9async 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
59async function testKyselyAnyInserts(db: Kysely<any>) {
60 const r1 = await db

Callers

nothing calls this directly

Calls 8

executeMethod · 0.65
selectMethod · 0.65
selectFromMethod · 0.65
asMethod · 0.65
litMethod · 0.65
refMethod · 0.65
whereRefMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…