Skip to content

Commit

Permalink
Convert True to true in query strings (#156)
Browse files Browse the repository at this point in the history
Fix #142
  • Loading branch information
nfx authored Jun 8, 2023
1 parent 087cf3f commit 1046ddb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion databricks/sdk/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,14 @@ def _authenticate(self, r: requests.PreparedRequest) -> requests.PreparedRequest
r.headers[k] = v
return r

@staticmethod
def _fix_query_string(query: Optional[dict] = None) -> Optional[dict]:
# Convert True -> "true" for Databricks APIs to understand booleans.
# See: https://github.com/databricks/databricks-sdk-py/issues/142
if query is None:
return None
return {k: v if type(v) != bool else ('true' if v else 'false') for k, v in query.items()}

def do(self,
method: str,
path: str,
Expand All @@ -863,7 +871,7 @@ def do(self,
headers = {'Accept': 'application/json', 'User-Agent': self._user_agent_base}
response = self._session.request(method,
f"{self._cfg.host}{path}",
params=query,
params=self._fix_query_string(query),
json=body,
headers=headers,
files=files,
Expand Down

0 comments on commit 1046ddb

Please sign in to comment.