drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too đŸ˜…
https://orm.drizzle.team
Apache License 2.0
23.14k stars 564 forks source link

[FEATURE]: Add support for sqlcommenter #2147

Open gusfune opened 5 months ago

gusfune commented 5 months ago

Describe what you want

sqlcommenter is a suite of middlewares/plugins that enable your ORMs to augment SQL statements before execution, with comments containing information about the code that caused its execution. This helps in easily correlating slow performance with source code and giving insights into backend database performance. In short it provides some observability into the state of your client-side applications and their impact on the database’s server-side.

https://google.github.io/sqlcommenter/

This can be achieved today with Drizzle on manual sql queries, but there is no way to use the native Drizzle selectors. Adding sqlcommenter would make easier to tag those, even though it's an "opinionated" library mostly used in Google Cloud.

Sample usage (options):

const result = await db.select().from(users).comment({ hello: "world" });
const result = await db.select().from(users).tag({ foo: "bar" });
mbrevda commented 1 month ago

see also https://github.com/drizzle-team/drizzle-orm/issues/1866