From 5091048ddb4147f17fe33564cb4f3f313bc75adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Koskim=C3=A4ki?= Date: Sat, 6 Jan 2024 12:17:45 +0200 Subject: [PATCH] v0.27.2 --- package.json | 2 +- src/query-builder/insert-query-builder.ts | 2 - src/query-builder/update-query-builder.ts | 2 - test/typings/test-d/kysely-any.test-d.ts | 58 ++++++++--------------- test/typings/test-d/update.test-d.ts | 4 +- 5 files changed, 23 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index dfc54305c..8dff0de08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kysely", - "version": "0.27.1", + "version": "0.27.2", "description": "Type safe SQL query builder", "repository": { "type": "git", diff --git a/src/query-builder/insert-query-builder.ts b/src/query-builder/insert-query-builder.ts index f5d62d42d..6405a9bbc 100644 --- a/src/query-builder/insert-query-builder.ts +++ b/src/query-builder/insert-query-builder.ts @@ -9,8 +9,6 @@ import { } from '../parser/select-parser.js' import { InsertExpression, - InsertObjectOrList, - InsertObjectOrListFactory, parseInsertExpression, } from '../parser/insert-values-parser.js' import { InsertQueryNode } from '../operation-node/insert-query-node.js' diff --git a/src/query-builder/update-query-builder.ts b/src/query-builder/update-query-builder.ts index 184df8303..8d9015e66 100644 --- a/src/query-builder/update-query-builder.ts +++ b/src/query-builder/update-query-builder.ts @@ -37,8 +37,6 @@ import { import { UpdateQueryNode } from '../operation-node/update-query-node.js' import { UpdateObjectExpression, - UpdateObject, - UpdateObjectFactory, ExtractUpdateTypeFromReferenceExpression, parseUpdate, } from '../parser/update-set-parser.js' diff --git a/test/typings/test-d/kysely-any.test-d.ts b/test/typings/test-d/kysely-any.test-d.ts index 729d529c3..74c849380 100644 --- a/test/typings/test-d/kysely-any.test-d.ts +++ b/test/typings/test-d/kysely-any.test-d.ts @@ -1,59 +1,41 @@ -import { - DeleteResult, - InsertResult, - Kysely, - UpdateResult, - expressionBuilder, -} from '..' +import { DeleteResult, InsertResult, Kysely, UpdateResult } from '..' import { expectType } from 'tsd' async function testKyselyAnySelects(db: Kysely) { const r1 = await db.selectFrom('foo').select('bar').execute() - expectType< - { - bar: any - }[] - >(r1) + expectType<{ bar: any }[]>(r1) const r2 = await db.selectFrom('foo').select(['bar', 'baz']).execute() - expectType< - { - bar: any - baz: any - }[] - >(r2) + expectType<{ bar: any; baz: any }[]>(r2) const r3 = await db.selectFrom('foo').select('foo.bar').execute() - expectType< - { - bar: any - }[] - >(r3) + expectType<{ bar: any }[]>(r3) const r4 = await db .selectFrom('foo') .select(['spam', 'foo.bar', 'foo.baz']) .execute() - expectType< - { - spam: any - bar: any - baz: any - }[] - >(r4) + expectType<{ spam: any; bar: any; baz: any }[]>(r4) const r5 = await db .selectFrom(['foo1', 'foo2']) .select(['spam', 'foo1.bar', 'foo2.baz', 'doesnotexists.fux']) .execute() - expectType< - { - spam: any - bar: any - baz: any - fux: never - }[] - >(r5) + expectType<{ spam: any; bar: any; baz: any; fux: never }[]>(r5) + + const r6 = await db + .selectFrom('foo') + .select((eb) => [ + eb.lit(1).as('baz'), + eb.ref('foo.bar').as('bar'), + eb + .selectFrom('bar') + .select('spam') + .whereRef('foo.id', '=', 'bar.id') + .as('spam'), + ]) + .executeTakeFirstOrThrow() + expectType<{ bar: any; spam: any; baz: 1 }>(r6) } async function testKyselyAnyInserts(db: Kysely) { diff --git a/test/typings/test-d/update.test-d.ts b/test/typings/test-d/update.test-d.ts index 2fe47cb02..add6741dd 100644 --- a/test/typings/test-d/update.test-d.ts +++ b/test/typings/test-d/update.test-d.ts @@ -36,7 +36,7 @@ async function testUpdate(db: Kysely) { db .updateTable('pet as p') .where('p.id', '=', '1') - .set({ not_a_column: 'Fluffy' }) + .set({ name: 'Fluffy', not_a_column: 'not_a_column' }) ) // Non-existent column in a callback @@ -44,7 +44,7 @@ async function testUpdate(db: Kysely) { db .updateTable('pet as p') .where('p.id', '=', '1') - .set((eb) => ({ not_a_column: 'Fluffy' })) + .set((eb) => ({ not_a_column: eb.val('not_a_column') })) ) // GeneratedAlways column is not allowed to be updated