drizzle-team / drizzle-team/drizzle-orm

[BUG]:

Open
#1,826 8 comments 9 reactions 1 assignee Assigned to @L-Mario564 View on GitHub
good first issue has-pr improvement priority qb/crud
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.3

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

n/a

### Describe the Bug

Conditional helper functions such as `isNull`, `isNotNull`, `exists`, `notExists` cannot be used within a query select, without returning an `unknown` type.

```typescript
const results = await db
.select({
id: table.id,
has_title_orm: isNotNull(table.name),
has_title_sql: sql`${table.name} IS NOT NULL`,
})
.from(table);

results[0].has_title_orm; // unknown type
results[0].has_title_sql; // boolean type
```

### Expected behavior

The `sql` wrapper used should be able to be typed for these boolean returns. I can imagine that there's a circumstance where you might not want to, given the fact these query helpers can be used in other places?

### Environment & setup

Example Stackblitz: https://stackblitz.com/edit/typescript-5bbctn?file=index.ts

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.