Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
NamespaceKnowhereProvider,
SectionRow,
UnitRow,
knowhere_database_url,
)
from shared.services.retrieval.nav.nav_map_scores import (
build_score_units,
Expand Down Expand Up @@ -174,3 +175,18 @@ def test_streaming_scorer_preserves_duplicate_id_eager_semantics() -> None:
}

assert score_unit_stream_hybrid_all(lambda: rows, "alpha beta") == eager_scores


def test_native_chunk_store_strips_async_driver_from_database_url(
monkeypatch: Any,
) -> None:
monkeypatch.setenv(
"DATABASE_URL",
"postgresql+asyncpg://prod-user:prod-password@db.example/knowhere",
)
monkeypatch.delenv("KNOWHERE_DATABASE_URL", raising=False)

assert (
knowhere_database_url()
== "postgresql://prod-user:prod-password@db.example/knowhere"
)
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ def knowhere_database_url() -> str:
or str(os.environ.get("DATABASE_URL") or "").strip()
)
if configured:
return configured.replace("postgresql+asyncpg", "postgresql+psycopg2")
# ``ReadOnlyChunkStore`` uses psycopg2's native connector, which
# accepts libpq URLs but not SQLAlchemy's ``+driver`` suffix.
return configured.replace("postgresql+asyncpg://", "postgresql://", 1).replace(
"postgresql+psycopg2://", "postgresql://", 1
)
return _DEFAULT_DSN


Expand Down
Loading