drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: Support identifiers in ORDER BY and GROUP BY clauses
- 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
Assessment
This issue has not been assessed yet.