Skip to content

Commit

Permalink
fix: postgresql url query param (#5659)
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerHYang authored Dec 9, 2024
1 parent d6382dc commit 5f51386
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/phoenix/db/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_async_db_url(connection_str: str) -> URL:
# So we need to parse them out manually
if url.username and url.password:
url = url.set(
query={"user": url.username, "password": url.password},
query={**url.query, "user": url.username, "password": url.password},
password=None,
username=None,
)
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/db/test_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ def test_get_async_sqlite_db_url() -> None:

def test_get_async_postgresql_db_url() -> None:
# Test credentials as url params
connection_str = "postgresql://@localhost:5432/phoenix?user=user&password=password"
connection_str = "postgresql://user:password@localhost:5432/phoenix?ssl=require"
url = get_async_db_url(connection_str)
assert url.drivername == "postgresql+asyncpg"
assert url.database == "phoenix"
assert url.host == "localhost"
assert url.query["user"] == "user"
assert url.query["password"] == "password"
assert url.query["ssl"] == "require"

# Test credentials as part of the url
connection_str = "postgresql://user:password@localhost:5432/phoenix"
Expand Down

0 comments on commit 5f51386

Please sign in to comment.