cubicweb #2236985 rqlrewrite fails to remove rewritten entry for unsupported constraint and then crash [done]

A KeyError is raised when:

  • multiple snipset is to be inserted on a statement
  • some supported snipset adds ambiguity (increase the number of solution)
  • some unsupported snipset adds new variable
  • The new variable require rewritting
File "/home/pyves/src/fcw/cubicweb/rqlrewrite.py", line 185, in rewrite
  newsolutions = self.remove_ambiguities(snippets, newsolutions)
File "/home/pyves/src/fcw/cubicweb/rqlrewrite.py", line 436, in remove_ambiguities
  variantes = self.build_variantes(newsolutions)
File "/home/pyves/src/fcw/cubicweb/devtools/repotest.py", line 340, in _build_variantes
  variantes = _orig_build_variantes(self, newsolutions)
File "/home/pyves/src/fcw/cubicweb/rqlrewrite.py", line 470, in build_variantes
  variante.append( (key, sol[newvar]) )
KeyError: u'D'

This happen because the mechanism removing unsupported snipset does not remove entry in self.rewritten when it removes entry from self.select.defined_vars.

Iteration on self.rewritten then crash because values of rewritten are expected to be found in solution.

---

Removing rewritten at the same time than defined_vars should be enouth to remove the bug.

prioritynormal
typebug
done in<not specified>
load1.000
load left0.000
closed by#f23782a2cdee rqlrewrite: remove element in rewritten when we remove them from the select (closes #2236985)