Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit dc4e9cc

Browse files
Merge branch 'abs' of https://github.com/blueyed/databases into blueyed-abs
2 parents 9cb2202 + 578ffc3 commit dc4e9cc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

databases/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,10 @@ def netloc(self) -> typing.Optional[str]:
362362

363363
@property
364364
def database(self) -> str:
365-
return self.components.path.lstrip("/")
365+
path = self.components.path
366+
if path[:1] == "/":
367+
return path[1:]
368+
return path
366369

367370
@property
368371
def options(self) -> dict:

tests/test_database_url.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,9 @@ def test_replace_database_url_components():
5151
new = u.replace(database="test_" + u.database)
5252
assert new.database == "test_mydatabase"
5353
assert str(new) == "sqlite:///test_mydatabase"
54+
55+
u = DatabaseURL("sqlite:////absolute/path")
56+
assert u.database == "/absolute/path"
57+
new = u.replace(database=u.database + "_test")
58+
assert new.database == "/absolute/path_test"
59+
assert str(new) == "sqlite:////absolute/path_test"

0 commit comments

Comments
 (0)