tediousjs / tedious

Node TDS module for connecting to SQL Server databases.
http://tediousjs.github.io/tedious/
MIT License
1.58k stars 439 forks source link

feat: add `databaseMirroringPartner` event handler #1671

Open nick-w-nick opened 3 weeks ago

nick-w-nick commented 3 weeks ago

This PR is to fix #1669, where the library throws an unhandled exception if it encounters an ENVCHANGE event of type DATABASE_MIRRORING_PARTNER.

This behavior isn't explicitly documented, but there have been a few issues brought up regarding this functionality in the past, and it has been stated that tedious does not plan to support failover partners. While that may be the case, this event being emitted by SQL Server is causing Tedious to crash completely rather than simply ignoring it as you would expect.

The changes in this PR are to create the databaseMirroringPartner event emitter and register the necessary handler methods in the associated token handler classes, to prevent the default behavior of throwing an Unexpected token error.

To clarify, this does not implement mirroring functionality or anything of the sort, it simply updates the default behavior to allow the event to pass through and be ignored, rather than unnecessarily throwing an unhandled exception.

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.80%. Comparing base (ebb023e) to head (19ab9eb).

Files with missing lines Patch % Lines
src/token/handler.ts 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1671 +/- ## ========================================== - Coverage 78.81% 78.80% -0.02% ========================================== Files 90 90 Lines 4877 4878 +1 Branches 918 918 ========================================== Hits 3844 3844 - Misses 735 736 +1 Partials 298 298 ```

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