Skip to content

Commit 8e5bd2b

Browse files
committed
Fix save_db_settings overwriting db_type when URL is empty
Legacy save_db_settings called _detect_db_type("") which always returned "sqlite", overwriting the correct db_type on the active connection when only mode/limits were being saved.
1 parent 6f14f1c commit 8e5bd2b

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

app/settings_db.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,14 @@ def save_db_settings(url: str = "", mode: str = "", allow_destructive: bool = Fa
294294
existing = conn.execute("SELECT id, url FROM db_connections WHERE is_active = 1").fetchone()
295295
if existing:
296296
new_url = encrypt(url) if url else (existing["url"] or "")
297-
conn.execute(
298-
"UPDATE db_connections SET url=?, mode=?, allow_destructive=?, db_type=?"
299-
" WHERE is_active=1",
300-
(new_url, mode or "read-only", int(allow_destructive), _detect_db_type(url)),
301-
)
297+
# Only update db_type if a new URL was provided
298+
updates = "UPDATE db_connections SET url=?, mode=?, allow_destructive=?"
299+
params: list = [new_url, mode or "read-only", int(allow_destructive)]
300+
if url:
301+
updates += ", db_type=?"
302+
params.append(_detect_db_type(url))
303+
updates += " WHERE is_active=1"
304+
conn.execute(updates, params)
302305
else:
303306
conn.execute(
304307
"INSERT INTO db_connections"

0 commit comments

Comments
 (0)