Skip to content

Commit

Permalink
Merge pull request #18 from dimagi/joinfield
Browse files Browse the repository at this point in the history
Hack around missing QJoin.join_field
  • Loading branch information
millerdev committed Apr 24, 2020
2 parents fd33575 + f3795a8 commit 0fc7da7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions django_cte/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self, parent_alias, table_name, table_alias,
self.table_name = table_name
self.table_alias = table_alias
self.on_clause = on_clause
self.join_field = _get_join_field(on_clause)
self.join_type = join_type # LOUTER or INNER
self.nullable = join_type != INNER if nullable is None else nullable

Expand Down Expand Up @@ -59,3 +60,10 @@ def __eq__(self, other):
self.join_type == other.join_type
)
return False


def _get_join_field(on_clause):
# HACK this seems fragile
# The LHS field _should_ be first, but what if it's not?
# What if there is more than one condition and by extension join field?
return on_clause.get_group_by_cols()[0].field

0 comments on commit 0fc7da7

Please sign in to comment.