microsoft / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
283 stars 63 forks source link

Fix named pipe path handling to preserve "." #178

Closed shueybubbles closed 6 months ago

shueybubbles commented 7 months ago

Fix for https://github.com/microsoft/go-sqlcmd/issues/506

Sqlcmd converts the named pipe given by the user into its component parts to include in a URL connection string it hands to the driver. When the named pipe path uses . as the server name, the driver converts it to localhost so connections to the browser service work. However, for some named pipe SQL connections like those to Windows Internal Database, the reconstructed pipe name has to use . as the server component.

This change preserves . in the pipe name while still switching to localhost for the SQL browser calls.

Built sqlcmd with a local version of the driver with this fix:

C:\git\go-sqlcmd\cmd\modern>modern -S np:\\.\pipe\microsoft##wid\tsql\query -Q "select @@version"

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2014 (SP2-GDR) (KB4057120) - 12.0.5214.6 (X64)
        Jan  9 2018 15:03:12
        Copyright (c) Microsoft Corporation
        Windows Internal Database (64-bit) on Windows NT 6.3 <X64> (Build 17763: ) (Hypervisor)

(1 row affected)
codecov-commenter commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 74.53%. Comparing base (fe7c3d4) to head (d4192bc).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #178 +/- ## ========================================== - Coverage 74.72% 74.53% -0.20% ========================================== Files 32 32 Lines 6298 6298 ========================================== - Hits 4706 4694 -12 - Misses 1316 1324 +8 - Partials 276 280 +4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.