Skip to content

[WIP] Format SQL query logs with DECLARE statements#169

Draft
Claude wants to merge 1 commit into
mainfrom
claude/format-sql-query-logs
Draft

[WIP] Format SQL query logs with DECLARE statements#169
Claude wants to merge 1 commit into
mainfrom
claude/format-sql-query-logs

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented May 19, 2026

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.


This section details on the original issue you should resolve

<issue_title>Format SQL query logs with DECLARE statements and readable multi-line output</issue_title>
<issue_description>When SQL queries are logged (slow queries, errors, etc.), the output is currently hard-to-read pino JSON with escaped newlines/tabs. It should instead print as proper multi-line SQL with the parameters declared at the top.

  • Current Output (from logs)
"query":"SELECT *\nFROM Table\tWHERE Id = @Id",
"parameters":{"Id":{"name":"Id","io":1,"value":5}}
  • Desired Output
DECLARE @Id INT = 5

SELECT *
FROM Table WHERE Id = @Id
  • What Changes Are Needed

Create a formatting helper that takes { query, parameters } and returns a string like:

DECLARE @Param1 TYPE1 = Value1
DECLARE @Param2 TYPE2 = Value2

SELECT ...
  1. Map mssql type constructors (Int, VarChar, DateTime2, Bit, etc.) to their SQL type names.
  2. Handle string quoting ('value'), NULL (= NULL), and date formatting in DECLARE lines.
  3. Preserve actual newlines/tabs in the query (don't JSON-escape them).
  4. Apply the helper at all 3 logging sites in the MSSQL module — slow query threshold logger, max query time warning logger, and query error logger.</issue_description>

Comments on the Issue (you are @claude[agent] in this section)

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.

Format SQL query logs with DECLARE statements and readable multi-line output

2 participants