Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/orm/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getInstanceStateFromItem } from './identity-map';
import { getClassTypeFromInstance } from '@deepkit/core';

export type FlattenIfArray<T> = T extends Array<any> ? T[0] : T;
export type FieldName<T> = keyof T & string;
export type FieldName<T> = { [Key in keyof T & string]: T[Key] extends Function ? never : Key }[keyof T & string];

export function getClassSchemaInstancePairs<T extends OrmEntity>(items: Iterable<T>): Map<ReflectionClass<any>, T[]> {
const map = new Map<ReflectionClass<any>, T[]>();
Expand Down
3 changes: 2 additions & 1 deletion packages/orm/tests/query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -54,7 +55,7 @@ test('query lift', async () => {

class UserQuery<T extends { username: string }> extends MyBase<T> {
findAllUserNames() {
return this.findField('username');
return this.findField('username' as FieldName<T>);
}

//query classes should be able to infer the actual used class
Expand Down