Skip to content

Commit

Permalink
Changed sqla client to add query params as string
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fleming authored and capitancambio committed Apr 6, 2023
1 parent 40acc55 commit f34d6a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/tentaclio/clients/sqla_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def _connect(self) -> Connection:
port=self.port,
database=self.database,
)
if self.url.query_string:
parsed_url.update_query_string(self.url.query_string)
if self.engine is None:
self.engine = create_engine(
parsed_url,
Expand Down
7 changes: 7 additions & 0 deletions src/tentaclio/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class URL:
_port: Optional[int] = None
_path: str
_query: Optional[Dict[str, str]] = None
_query_string: Optional[str] = None

def __init__(self, url: str) -> None:
"""Create a url by parsing the parametre."""
Expand All @@ -57,6 +58,7 @@ def _parse_url(self) -> None:
self._hostname = parsed_url.hostname
self._port = parsed_url.port
self._path = parsed_url.path
self._query_string = parsed_url.query

# Replace %xx escapes - ONLY for username & password
if parsed_url.username and self._username:
Expand Down Expand Up @@ -168,6 +170,11 @@ def query(self) -> Optional[Dict[str, str]]:
"""Access the query."""
return self._query

@property
def query_string(self) -> Optional[str]:
"""Access the query string."""
return self._query_string

@property
def url(self) -> str:
"""Return the original url."""
Expand Down

0 comments on commit f34d6a0

Please sign in to comment.