

@returns_clone
def join(self, dest, join_type=None, on=None):
    src = self._query_ctx
    if (not on):
        require_join_condition = (isinstance(dest, SelectQuery) or (isclass(dest) and (not src._meta.rel_exists(dest))))
        if require_join_condition:
            raise ValueError('A join condition must be specified.')
    elif isinstance(on, basestring):
        on = src._meta.fields[on]
    self._joins.setdefault(src, [])
    self._joins[src].append(Join(src, dest, join_type, on))
    if (not isinstance(dest, SelectQuery)):
        self._query_ctx = dest

dataset/ETHPy150Open coleifer/peewee/peewee.py Query.join/original