drizzle-team / drizzle-team/drizzle-orm

[BUG]: Fields related to the Query API have to be of type <T | undefined>

Open
#1,924 2 comments 0 reactions 0 assignees View on GitHub
improvement priority rqb
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.29.2

### What version of `drizzle-kit` are you using?

0.20.13

### Describe the Bug

When getting related fields using the findFirst or findMany methods, the appended fields that I bring with "with" should be of type so that in case nothing is found it is safe.

### Expected behavior

```ts
const lesson = db.query.lessonTable
.findFirst({
where: (columns, { eq }) => eq(columns.id, "lessonId"),
with:{
author: true
},
});
```
Trying to access to some author properties without null checking have to thow a TS error

### Environment & setup

development

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.