From f2dc66a2d4f1e8823246d1621b424e44ec423897 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Tue, 18 Feb 2025 12:27:01 +0100
Subject: [PATCH] On PlomDbConn init, access .default_path through PlomDbFile
 init (for its validations).

---
 py/db.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/py/db.py b/py/db.py
index e13ac14..ec8ab7a 100644
--- a/py/db.py
+++ b/py/db.py
@@ -124,11 +124,12 @@ class PlomDbFile:
 class PlomDbConn:
     """SQL connection to PlomDbFile."""
     default_path: Path
+    db_file_class = PlomDbFile
 
     def __init__(self, db_file: Optional[TypePlomDbFile] = None) -> None:
-        self._conn = sql_connect(
-                db_file.path if db_file else self.default_path,
-                autocommit=False)
+        # only access .default_path through db_file_class init, for validations
+        vetted = db_file if db_file else self.db_file_class(self.default_path)
+        self._conn = sql_connect(vetted.path, autocommit=False)
         # additional sqlite3.Connection shortcuts beyond .exec
         self.exec_script = self._conn.executescript
         self.commit = self._conn.commit
-- 
2.30.2