diff --git a/packages/orm/src/utils.ts b/packages/orm/src/utils.ts index 6842ee353..8b61c876a 100644 --- a/packages/orm/src/utils.ts +++ b/packages/orm/src/utils.ts @@ -16,7 +16,7 @@ import { getInstanceStateFromItem } from './identity-map'; import { getClassTypeFromInstance } from '@deepkit/core'; export type FlattenIfArray = T extends Array ? T[0] : T; -export type FieldName = keyof T & string; +export type FieldName = { [Key in keyof T & string]: T[Key] extends Function ? never : Key }[keyof T & string]; export function getClassSchemaInstancePairs(items: Iterable): Map, T[]> { const map = new Map, T[]>(); diff --git a/packages/orm/tests/query.spec.ts b/packages/orm/tests/query.spec.ts index 507fc1834..79f3bfdbe 100644 --- a/packages/orm/tests/query.spec.ts +++ b/packages/orm/tests/query.spec.ts @@ -4,6 +4,7 @@ import { assert, IsExact } from 'conditional-type-checks'; import { Database } from '../src/database'; import { MemoryDatabaseAdapter, MemoryQuery } from '../src/memory-db'; import { Query } from '../src/query'; +import { FieldName } from "../src/utils"; test('query select', async () => { class s { @@ -54,7 +55,7 @@ test('query lift', async () => { class UserQuery extends MyBase { findAllUserNames() { - return this.findField('username'); + return this.findField('username' as FieldName); } //query classes should be able to infer the actual used class