drizzle-team / drizzle-team/drizzle-orm
[BUG]: isNotNull does not impact type of returned column
- 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.33.0
### What version of `drizzle-kit` are you using?
0.24.2
### Describe the Bug
Say you have this schema
```
export const user = pgTable("user", {
name: varchar("name").notNull(),
age: integer("age").notNull(),
})
export const pet = pgTable("pet", {
name: varchar("name").notNull(),
age: integer("age")
})
```
And you want to combine two queries like this:
```
const humanAge=db.select({age:user.age}).from(user)
const animalAge = db.select({age:pet.age}).from(pet).where(isNotNull(pet.age))
const age = union(humanAge,animalAge)
```
Even though we ensured that age can never be null (`isNotNull...`), Typescript complains: ```Type 'number | null' is not assignable to type 'number' ```
### Expected behavior
{ age: number }
### Environment & setup
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.