Skip to content

Commit 9be521b

Browse files
committed
Fix SQL server instance names
1 parent ddd03ae commit 9be521b

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ _When adding new entries to the changelog, please include issue/PR numbers where
77
## 0.15.3 (UNRELEASED)
88

99
- Replaces minimal patches with delta-filters - a more general-purpose way of filtering parts (inserts, updates, deletes) of JSON diffs when not all parts are required. [#998](https://github.com/koordinates/kart/pull/998)
10+
- Remove automatic resolution of `localhost` before calling MSSQL driver. Fixes SQL Server instance names issue. [#999](https://github.com/koordinates/kart/issues/999)
1011

1112
## 0.15.2
1213

kart/sqlalchemy/base.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ def _pool_class(cls):
5252
# But this fix is simpler for now: disable the pool during testing.
5353
return NullPool if "PYTEST_CURRENT_TEST" in os.environ else None
5454

55-
@classmethod
56-
def _replace_localhost_with_ip(cls, url_netloc):
57-
def _get_localhost_ip(*args, **kwargs):
58-
return socket.gethostbyname("localhost")
59-
60-
return re.sub(r"\blocalhost\b", _get_localhost_ip, url_netloc)
61-
6255
@classmethod
6356
def _append_query_to_url(cls, uri, new_query_dict):
6457
url = urlsplit(uri)

kart/sqlalchemy/sqlserver.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ def create_engine(cls, msurl):
3131
{"driver": cls.get_sqlserver_driver(), "Application Name": "kart"},
3232
)
3333

34-
# SQL Server driver prefers 127.0.0.1 or similar to localhost.
35-
url_netloc = cls._replace_localhost_with_ip(url.netloc)
36-
37-
msurl = urlunsplit([cls.INTERNAL_SCHEME, url_netloc, url.path, url_query, ""])
34+
msurl = urlunsplit([cls.INTERNAL_SCHEME, url.netloc, url.path, url_query, ""])
3835

3936
engine = sqlalchemy.create_engine(msurl, poolclass=cls._pool_class())
4037
return engine

0 commit comments

Comments
 (0)