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

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

/ sqlc Public

[Feature] Add query metadata comments - #4444

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

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

Conversation

DerekTBrown commented May 14, 2026
edited
Loading

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

DerekTBrown changed the title [codex] Add query metadata comments [Feature] Add query metadata comments May 14, 2026
DerekTBrown marked this pull request as ready for review May 14, 2026 16:37
kyleconroy closed this May 15, 2026

Copy link
Copy Markdown
Collaborator

@DerekTBrown please open up an issue or a discussion with your feature request before submitting any code. Thanks.

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

2 participants


Back | FazBrowse Home | New Git URL