Skip to content
Draft
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
12 changes: 6 additions & 6 deletions apis/ql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,17 @@ type SELECT_one =
// calling with class
(<T extends ArrayConstructable>
(entityType: T, projection?: Projection<QLExtensions<SingularInstanceType<T>>>)
=> Awaitable<SELECT<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T> | null>)
=> Awaitable<SELECT<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T> | null | undefined>)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there actually instances in which null is returned, or should we replace all instances of null with undefined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of any but at the least the runtime doesn't make the assumption that only undefined is allowed.

@daogrady daogrady Nov 25, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 I mean... SELECT null; is valid SQL. Although I wouldn't know how to do this exact query through our fluent API. I think the null type is currently there to express "nothing found". If this is supposed to be done through undefined, then we can fully replace it imho.

@johannes-vogel johannes-vogel Nov 25, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-11-25 at 09 52 27

What I also wanted to express in the comment of the issue is that also plugins can implement services that support the query language. In these cases, it's not in our control what the service will return for SELECT.one. Therefore, I thought accepting null and undefined is more safe.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I think we should stick with what our default logic dictates, or else we'd have to resort to any in all cases, as we'd always have to expect plugins to return something unexpected.

&
(<T extends ArrayConstructable>
(entityType: T, primaryKey: PK, projection?: Projection<QLExtensions<SingularInstanceType<T>>>)
=> Awaitable<SELECT<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T> | null>)
=> Awaitable<SELECT<SingularInstanceType<T>, SELECT_one>, SingularInstanceType<T> | null | undefined>)

& ((entity: EntityDescription, primaryKey?: PK, projection?: Projection<unknown>) => SELECT<_TODO, SELECT_one>)
& (<T> (entity: T[], projection?: Projection<T>) => Awaitable<SELECT<T, SELECT_one>, T | null>)
& (<T> (entity: T[], primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT<T, SELECT_one>, T | null>)
& (<T> (entity: { new(): T }, projection?: Projection<T>) => Awaitable<SELECT<T, SELECT_one>, T | null>)
& (<T> (entity: { new(): T }, primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT<T, SELECT_one>, T | null>)
& (<T> (entity: T[], projection?: Projection<T>) => Awaitable<SELECT<T, SELECT_one>, T | null | undefined>)
& (<T> (entity: T[], primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT<T, SELECT_one>, T | null | undefined>)
& (<T> (entity: { new(): T }, projection?: Projection<T>) => Awaitable<SELECT<T, SELECT_one>, T | null | undefined>)
& (<T> (entity: { new(): T }, primaryKey: PK, projection?: Projection<T>) => Awaitable<SELECT<T, SELECT_one>, T | null | undefined>)
& ((subject: ref) => SELECT<_TODO>)

type SELECT_from =
Expand Down
Loading