FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Feature] Add query metadata comments by DerekTBrown · Pull Request #4490 · sqlc-dev/sqlc · GitHub

/ sqlc Public

[Feature] Add query metadata comments - #4490

Open
DerekTBrown wants to merge 1 commit into
sqlc-dev:mainfrom
DerekTBrown:codex/query-metadata-comments
Open

[Feature] Add query metadata comments#4490
DerekTBrown wants to merge 1 commit into
sqlc-dev:mainfrom
DerekTBrown:codex/query-metadata-comments

Conversation

Copy link
Copy Markdown

Fixes #4489

Problem Statement

Database monitoring and tracing tools (ex. Datadog) rely on metadata comments to trace SQL statements. I am looking for an easy way to inject these into SQLC-generated statements, improving traceability and auditability of SQL queries.

Proposal

This adds a query_comments config block that prepends generated SQL with structured metadata comments in either sqlcommenter or marginalia format based on the tags specified in the SQLC comment:

version: "2"
sql:
  - schema: "schema.sql"
    query_comments:
      enabled: true
      format: "sqlcommenter"
      tags:
        - name
        - filename

All generated SQL statements will then contain the tracking comment:

/*sqlc_name='GetAuthor',sqlc_filename='query.sql'*/
-- name: GetAuthor :one
SELECT id, name FROM authors WHERE id = $1

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Successfully merging this pull request may close these issues.

Add configurable SQL metadata comments to generated queries

1 participant


Back | FazBrowse Home | New Git URL