#455 fix improper quoting of on clause

This commit is contained in:
collerek
2021-12-16 18:19:55 +01:00
parent 1b9a59b49d
commit f245e91740
4 changed files with 74 additions and 3 deletions

View File

@ -108,7 +108,14 @@ class SqlJoin:
:rtype: sqlalchemy.text
"""
left_part = f"{self.next_alias}_{to_clause}"
right_part = f"{previous_alias + '_' if previous_alias else ''}{from_clause}"
if not previous_alias:
dialect = self.main_model.Meta.database._backend._dialect
table, column = from_clause.split(".")
quotter = dialect.identifier_preparer.quote
right_part = f"{quotter(table)}.{quotter(column)}"
else:
right_part = f"{previous_alias}'_'{from_clause}"
return text(f"{left_part}={right_part}")
def build_join(self) -> Tuple[List, sqlalchemy.sql.select, List, OrderedDict]:

View File

@ -913,7 +913,7 @@ class QuerySet(Generic[T]):
except ormar.NoMatch:
return None
async def get(self, *args: Any, **kwargs: Any) -> "T":
async def get(self, *args: Any, **kwargs: Any) -> "T": # noqa: CCR001
"""
Get's the first row from the db meeting the criteria set by kwargs.