Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: use text() wrapper for SQLAlchemy 2.0 session health check (#2353)

LearningCircuit1c5accc2f6e4
diff --git a/src/local_deep_research/database/thread_local_session.py b/src/local_deep_research/database/thread_local_session.py
index d684e4c1e6..c053ed5cf0 100644
--- a/src/local_deep_research/database/thread_local_session.py
+++ b/src/local_deep_research/database/thread_local_session.py
@@ -5,6 +5,7 @@ Each thread gets its own database session that persists for the thread's lifetim
import threading
from typing import Optional, Dict, Tuple
+from sqlalchemy import text
from sqlalchemy.orm import Session
from loguru import logger
@@ -38,7 +39,7 @@ class ThreadLocalSessionManager:
# Verify it's still valid
try:
# Simple query to test connection
- self._local.session.execute("SELECT 1")
+ self._local.session.execute(text("SELECT 1"))
return self._local.session
except Exception:
# Session is invalid, will create a new one
diff --git a/tests/database/test_thread_local_session.py b/tests/database/test_thread_local_session.py
index 8fdbc56c58..fe30aab5eb 100644
--- a/tests/database/test_thread_local_session.py
+++ b/tests/database/test_thread_local_session.py
@@ -79,7 +79,9 @@ class TestThreadLocalSessionManager:
# Should return the existing session
assert result is mock_existing_session
- mock_existing_session.execute.assert_called_once_with("SELECT 1")
+ # text() objects aren't equal by default, so check the string representation
+ call_args = mock_existing_session.execute.call_args[0][0]
+ assert str(call_args) == "SELECT 1"
def test_get_session_creates_new_when_existing_invalid(self):
"""Test that get_session creates new session when existing is invalid."""