fix: strip only the driver prefix from an info message - #448
Merged
Conversation
res.info reports a diagnostic with the driver's component chain removed, e.g. "[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]". It was removed by cutting at the last ']' anywhere in the string, so any message carrying a bracket of its own lost everything up to it: print 'select * from [dbo].[my_table]' -> '' print 'ends with ]' -> '' Generated SQL is largely bracketed identifiers, so this hit the common reason to PRINT anything, and it hit every caller of the promises api because they all aggregate through here. The whole message was lost, silently, with nothing left to suggest the text had ever been there. The chain is now matched at the start of the message rather than searched for at the end. Components from the drivers and managers we know - Microsoft, the ODBC Driver Manager, ODBC Driver NN for SQL Server, SQL Server, the Native Client names, unixODBC and iODBC - are removed one after another, which leaves a message that itself opens with a bracketed identifier intact. Anything else still gets its leading chain of bracketed groups removed, so an unrecognised driver such as FreeTDS is no worse off than before; a message of its own that opens with a bracket is the one case that cannot be told apart from a component, and losing a leading group beats losing the whole line. stripDriverPrefix is exported so the conversion can be tested without a server. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FS9t73svfSHXWoBUehTKA2
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
res.info reports a diagnostic with the driver's component chain removed, e.g. "[Microsoft][ODBC Driver 18 for SQL Server][SQL Server]". It was removed by cutting at the last ']' anywhere in the string, so any message carrying a bracket of its own lost everything up to it:
print 'select * from [dbo].[my_table]' -> ''
print 'ends with ]' -> ''
Generated SQL is largely bracketed identifiers, so this hit the common reason to PRINT anything, and it hit every caller of the promises api because they all aggregate through here. The whole message was lost, silently, with nothing left to suggest the text had ever been there.
The chain is now matched at the start of the message rather than searched for at the end. Components from the drivers and managers we know - Microsoft, the ODBC Driver Manager, ODBC Driver NN for SQL Server, SQL Server, the Native Client names, unixODBC and iODBC - are removed one after another, which leaves a message that itself opens with a bracketed identifier intact. Anything else still gets its leading chain of bracketed groups removed, so an unrecognised driver such as FreeTDS is no worse off than before; a message of its own that opens with a bracket is the one case that cannot be told apart from a component, and losing a leading group beats losing the whole line.
stripDriverPrefix is exported so the conversion can be tested without a server.
Claude-Session: https://claude.ai/code/session_01FS9t73svfSHXWoBUehTKA2