drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: Support identifiers in ORDER BY and GROUP BY clauses

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

Description

### Feature hasn't been suggested before.

- [x] I have verified this feature I'm about to request hasn't been suggested before.

### Describe the enhancement you want to request

Having `.orderBy` and `groupBy` accept `Name` arguments (e.g. `sql.identifier("foo")`) would improve their ergonomics. We wouldn't need to resort to the function signature to reference aliased columns in these clauses.

The following snippets should be equivalent:

```ts
db
.select({ now: sql`now()`.as('now') })
.groupBy(table => table.now)
```

```ts
db
.select({ now: sql`now()`.as('now') })
.groupBy(sql.identifier('now'))
```

The former works fine, whereas the latter does not.

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.