Skip to content

Commit

Permalink
Fix restoring Data Store with incomplete URL
Browse files Browse the repository at this point in the history
Don't try to use an incomplete URL when constructing a Data Store.
This is a plausible situation when project is saved and closed before
the database URL is fully defined.

Re spine-tools/Spine-Toolbox#2915
  • Loading branch information
soininen committed Aug 9, 2024
1 parent c937af9 commit ea5d579
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions spine_items/data_store/data_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, name, description, x, y, toolbox, project, url):
self._purge_dialog = None
self._database_validator = DatabaseConnectionValidator(self)
db_map = self.get_db_map_for_ds()
# Notify db manager about the Data Stores in the project so it can notify abobut the dirtyness of them
# Notify db manager about the Data Stores in the project, so it can notify about the dirtiness of them
self._toolbox.db_mngr.add_data_store_db_map(db_map, self)

def get_db_map_for_ds(self):
Expand Down Expand Up @@ -100,9 +100,9 @@ def parse_url(self, url):
"""Return a complete url dictionary from the given dict or string"""
base_url = {"dialect": "", "username": "", "password": "", "host": "", "port": "", "database": "", "schema": ""}
if isinstance(url, dict):
if url.get("dialect") == "sqlite" and "database" in url and url["database"] is not None:
if url.get("dialect") == "sqlite" and (database := url.get("database")):
# Convert relative database path back to absolute
url["database"] = os.path.abspath(os.path.join(self._project.project_dir, url["database"]))
url["database"] = os.path.abspath(os.path.join(self._project.project_dir, database))
for key, value in url.items():
if value is not None:
base_url[key] = value
Expand Down

0 comments on commit ea5d579

Please sign in to comment.