-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support select queries without from clause (#605)
* support select queries without from clause * rename select --> selectNoFrom
- Loading branch information
Showing
9 changed files
with
240 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Kysely, SqlBool, sql } from '..' | ||
import { Database } from '../shared' | ||
import { expectType } from 'tsd' | ||
|
||
async function testSelectNoFrom(db: Kysely<Database>) { | ||
const r1 = await db | ||
.selectNoFrom(sql<'bar'>`select 'bar'`.as('foo')) | ||
.executeTakeFirstOrThrow() | ||
expectType<{ foo: 'bar' }>(r1) | ||
|
||
const r2 = await db | ||
.selectNoFrom((eb) => eb(eb.val(1), '=', 1).as('very_useful')) | ||
.executeTakeFirstOrThrow() | ||
expectType<{ very_useful: SqlBool }>(r2) | ||
|
||
const r3 = await db | ||
.selectNoFrom([ | ||
sql<'bar'>`select 'bar'`.as('foo'), | ||
db.selectFrom('pet').select('id').limit(1).as('pet_id'), | ||
]) | ||
.executeTakeFirstOrThrow() | ||
expectType<{ foo: 'bar'; pet_id: string | null }>(r3) | ||
|
||
const r4 = await db | ||
.selectNoFrom((eb) => [ | ||
eb(eb.val(1), '=', 1).as('very_useful'), | ||
eb.selectFrom('pet').select('id').limit(1).as('pet_id'), | ||
]) | ||
.executeTakeFirstOrThrow() | ||
expectType<{ very_useful: SqlBool; pet_id: string | null }>(r4) | ||
} |
d8aae75
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
kysely – ./
kysely-kysely-team.vercel.app
www.kysely.dev
kysely.dev
kysely-git-master-kysely-team.vercel.app