tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

Fix dsn for mssql named instances

Open adi1 opened this issue 1 year ago • 1 comments

Description

Remove port from an mssql dsn when using named instances.

Motivation and Context

MSSQL named instances use dynamic port numbers. You can either connect directly to the port, or to the named instance. Providing a DB URL like mssql://user:pass@host\instance/db?driver=FreeTDS will result in a DSN which looks like DRIVER=FreeTDS;SERVER=host\instance,1433;UID=user;PWD=pass; because the default port is added. This fails to connect, because the instance is not listening on port 1443.

https://github.com/tortoise/tortoise-orm/issues/1566

How Has This Been Tested?

I have only tested locally with and without named instances.

Checklist:

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ ] I have added the changelog accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
  • [ ] All new and existing tests passed.

adi1 avatar May 01 '24 09:05 adi1