tortoise-orm
tortoise-orm copied to clipboard
Fix dsn for mssql named instances
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.