831 return '%s=%s' % (lhssql, rhsconst.accept(self)) |
831 return '%s=%s' % (lhssql, rhsconst.accept(self)) |
832 if isinstance(rhsvar, Variable) and not rhsvar.name in self._varmap: |
832 if isinstance(rhsvar, Variable) and not rhsvar.name in self._varmap: |
833 # if the rhs variable is only linked to this relation, this mean we |
833 # if the rhs variable is only linked to this relation, this mean we |
834 # only want the relation to exists, eg NOT NULL in case of inlined |
834 # only want the relation to exists, eg NOT NULL in case of inlined |
835 # relation |
835 # relation |
836 if len(rhsvar.stinfo['relations']) == 1 and rhsvar._q_invariant: |
836 if rhsvar._q_invariant: |
|
837 sql = self._extra_join_sql(relation, lhssql, rhsvar) |
|
838 if sql: |
|
839 return sql |
837 return '%s IS NOT NULL' % lhssql |
840 return '%s IS NOT NULL' % lhssql |
838 if rhsvar._q_invariant: |
|
839 return self._extra_join_sql(relation, lhssql, rhsvar) |
|
840 return '%s=%s' % (lhssql, rhsvar.accept(self)) |
841 return '%s=%s' % (lhssql, rhsvar.accept(self)) |
841 |
842 |
842 def _process_relation_term(self, relation, rid, termvar, termconst, relfield): |
843 def _process_relation_term(self, relation, rid, termvar, termconst, relfield): |
843 if termconst or not termvar._q_invariant: |
844 if termconst or not termvar._q_invariant: |
844 termsql = termconst and termconst.accept(self) or termvar.accept(self) |
845 termsql = termconst and termconst.accept(self) or termvar.accept(self) |