drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: Query Comments

Open
#1,866 3 comments 27 reactions 0 assignees View on GitHub
enhancement qb/crud rqb
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Describe what you want

I think it would be nice to have a method to add a comment at the end of the query.

This would make it easier to know where the query is coming from. A popular provider that make good use of the comments are [Planetscale](https://planetscale.com/docs/concepts/query-insights#notable-queries), following the [google(sqlcommenter) format](https://google.github.io/sqlcommenter/).

I don't think is needed to ensure any formatting to it besides maybe not allowing `/*` and `*/`.

Suggestions:

Add a method called ".comment()", which receives a string and append it as a comment to the end of the query. e.g:
```ts
const result = await db.query.users.findMany({
with: {
posts: true
},
}).comment("application:'myproject', handler:'GO Api' ")
```

Or maybe:
```ts
const result = await db.query.users.findMany({
with: {
posts: true
},
comment: {
application: "myproject",
handler: "GO Api"
}
})
```

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.