Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for sqlcommenter #1428

Closed
wyaeld opened this issue Jan 11, 2022 · 2 comments
Closed

Support for sqlcommenter #1428

wyaeld opened this issue Jan 11, 2022 · 2 comments
Assignees

Comments

@wyaeld
Copy link

wyaeld commented Jan 11, 2022

I'm interested in feedback on whether this could be done, likely as a plugin or related library.

https://google.github.io/sqlcommenter/
https://cloud.google.com/sql/docs/postgres/using-query-insights#adding-tags-to-sql-queries

Sqlcomenter is a specification out of Google that their CloudSQL databases process, and allows tagged metadata to be included in queries, for things like tracing and performance management.
Functionally it is adding comments to the sql queries, in a similar way to how logback can pull metadata from the logging context.

Its supported in Spring/Hibernate, but I don't know how difficult or desirable to have it available in Exposed.

@floatdrop
Copy link

This could be done in similar way, as in #632 – through interceptors. But interceptors can not modify sql statement, which is needed by sqlcommenter to insert comment at the end of the query.

Other way is to inject sql comment into Query object, but it hard to wrap it into proxy object, because some fields (namely groupedByColumns, having, forUpdate and where) have private setters. But if they were protected (like distinct) – then we could define extension function comment, that returns TracedQuery with overriden prepareSQL.

I would love to hear back from maintainers – is it possible to add such functionality in Exposed?

@bog-walk
Copy link
Member

Both these approaches will become possible in upcoming version 0.53.0.

A new extension function comment() has been added to the Query class in PR #2088 .

And the Query class has been made more extensible by making copyTo() public in PR #2173 . An example of how this can be taken advantage of will be added to the site documentation, which will be synced with the upcoming release.

@bog-walk bog-walk self-assigned this Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants