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}}
DECLARE @Id INT = 5
SELECT *
FROM Table WHERE Id = @Id
Create a formatting helper that takes { query, parameters } and returns a string like:
DECLARE @Param1 TYPE1 = Value1
DECLARE @Param2 TYPE2 = Value2
SELECT ...
- Map mssql type constructors (Int, VarChar, DateTime2, Bit, etc.) to their SQL type names.
- Handle string quoting ('value'), NULL (= NULL), and date formatting in DECLARE lines.
- Preserve actual newlines/tabs in the query (don't JSON-escape them).
- 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.
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.
Create a formatting helper that takes { query, parameters } and returns a string like: