# HG changeset patch # User Sylvain Thénault # Date 1276157726 -7200 # Node ID c2e8290bc7b7618f9f8545b409b2ba8199ceb8ec # Parent 924ea48326c48a5bf7ae4d288920df1f0c9a4be8 [rql2sql] fix special 'X relation NULL' case (used by security insertion), broken by recent removal of IS operator in RQL diff -r 924ea48326c4 -r c2e8290bc7b7 server/sources/rql2sql.py --- a/server/sources/rql2sql.py Wed Jun 09 14:51:00 2010 +0200 +++ b/server/sources/rql2sql.py Thu Jun 10 10:15:26 2010 +0200 @@ -742,29 +742,29 @@ else: # no variables in the RHS sql = self._visit_attribute_relation(relation) + elif (rtype == 'is' and isinstance(rhs.children[0], Constant) + and rhs.children[0].eval(self._args) is None): + # special case "C is NULL" + if lhs.name in self._varmap: + lhssql = self._varmap[lhs.name] + else: + lhssql = lhs.accept(self) + return '%s%s' % (lhssql, rhs.accept(self)) + elif '%s.%s' % (lhs, relation.r_type) in self._varmap: + # relation has already been processed by a previous step + return '' + elif relation.optional: + # check it has not already been treaten (to get necessary + # information to add an outer join condition) + if relation in self._state.done: + return '' + # OPTIONAL relation, generate a left|right outer join + sql = self._visit_outer_join_relation(relation, rschema) + elif rschema.inlined: + sql = self._visit_inlined_relation(relation) else: - if rtype == 'is' and rhs.operator == 'IS': - # special case "C is NULL" - if lhs.name in self._varmap: - lhssql = self._varmap[lhs.name] - else: - lhssql = lhs.accept(self) - return '%s%s' % (lhssql, rhs.accept(self)) - if '%s.%s' % (lhs, relation.r_type) in self._varmap: - # relation has already been processed by a previous step - return - if relation.optional: - # check it has not already been treaten (to get necessary - # information to add an outer join condition) - if relation in self._state.done: - return - # OPTIONAL relation, generate a left|right outer join - sql = self._visit_outer_join_relation(relation, rschema) - elif rschema.inlined: - sql = self._visit_inlined_relation(relation) - else: - # regular (non final) relation - sql = self._visit_relation(relation, rschema) + # regular (non final) relation + sql = self._visit_relation(relation, rschema) return sql def _visit_inlined_relation(self, relation):