Skip to content

Commit

Permalink
user that don't use query_params should be able to set field aliases …
Browse files Browse the repository at this point in the history
…they want
  • Loading branch information
ns-gsavary committed Feb 17, 2022
1 parent 8444219 commit 8d47512
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aiochclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ async def _execute(
decode: bool = True,
) -> AsyncGenerator[Record, None]:
query_params = self._prepare_query_params(query_params)
query = query.format(**query_params)
if query_params:
query = query.format(**query_params)
need_fetch, is_json, statement_type = self._parse_squery(query)

if not is_json and json:
Expand Down
5 changes: 5 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,11 @@ async def test_exists_table(self):
exists = await self.ch.fetchrow("EXISTS TABLE all_types")
assert exists == {'result': 1}

async def test_no_params(self):
"""It should be possible to have the aliases we want if we don't use any params"""
res = await self.ch.fetchrow('SELECT 1 AS "{not_a_param}" FROM all_types')
assert res["{not_a_param}"] == 1


@pytest.mark.record
@pytest.mark.usefixtures("class_chclient")
Expand Down

0 comments on commit 8d47512

Please sign in to comment.