cubicweb #4598593 QueryError with UNION [open]

Here's an example that can be tested on this very forge:

Any X,LENGTH(DATA) WHERE F is File, F data DATA, PROJ screenshot F, PROJ name X

This works. So does:

Any 'foo', -1

However the union of both queries (which have identical types, namely String and Int):

(Any X,LENGTH(DATA) WHERE F is File, F data DATA, PROJ screenshot F, PROJ name X) UNION (Any 'foo', -1)

fails miserably with the following traceback:

File /usr/lib/python2.7/dist-packages/cubicweb/web/application.py, line 461, function core_handle
  result = controller.publish(rset=rset)
File /usr/lib/python2.7/dist-packages/cubicweb/web/views/basecontrollers.py, line 129, function publish
  view, rset = self._select_view_and_rset(rset)
File /usr/lib/python2.7/dist-packages/cubicweb/web/views/basecontrollers.py, line 143, function _select_view_and_rset
  rset = self.process_rql()
File /usr/lib/python2.7/dist-packages/cubicweb/web/controller.py, line 94, function process_rql
  return pp.process_query(rql)
File /usr/lib/python2.7/dist-packages/cubicweb/web/views/magicsearch.py, line 413, function process_query
  return proc.process_query(uquery)
File /usr/lib/python2.7/dist-packages/cubicweb/web/views/magicsearch.py, line 161, function process_query
  return self._cw.execute(*args)
File /usr/lib/python2.7/dist-packages/cubicweb/web/request.py, line 1062, function execute
  rset = self.cnx.execute(*args, **kwargs)
File /usr/lib/python2.7/dist-packages/cubicweb/repoapi.py, line 129, function check_open
  return func(clt_cnx, *args, **kwargs)
File /usr/lib/python2.7/dist-packages/cubicweb/repoapi.py, line 213, function execute
  rset = self._cnx.execute(*args, **kwargs)
File /usr/lib/python2.7/dist-packages/cubicweb/server/session.py, line 371, function wrapper
  return func(cnx, *args, **kwargs)
File /usr/lib/python2.7/dist-packages/cubicweb/server/session.py, line 381, function check_open
  return func(cnx, *args, **kwargs)
File /usr/lib/python2.7/dist-packages/cubicweb/server/session.py, line 1022, function execute
  rset = self._execute(self, rql, kwargs, build_descr)
File /usr/lib/python2.7/dist-packages/cubicweb/server/querier.py, line 592, function execute
  results = plan.execute()
File /usr/lib/python2.7/dist-packages/cubicweb/server/querier.py, line 176, function execute
  result = step.execute()
File /usr/lib/python2.7/dist-packages/cubicweb/server/ssplanner.py, line 374, function execute
  result = source.syntax_tree_search(cnx, union, args, cachekey, inputmap)
File /usr/lib/python2.7/dist-packages/cubicweb/server/sources/native.py, line 540, function syntax_tree_search
  sql, qargs, cbs = self._rql_sqlgen.generate(union, args, varmap)
File /usr/lib/python2.7/dist-packages/cubicweb/server/sources/rql2sql.py, line 732, function generate
  sql = self.union_sql(union)
File /usr/lib/python2.7/dist-packages/cubicweb/server/sources/rql2sql.py, line 743, function union_sql
  return '\nUNION ALL\n'.join(sqls)
File /usr/lib/python2.7/dist-packages/cubicweb/server/sources/rql2sql.py, line 742, function <genexpr>
  for select in union.children)
File /usr/lib/python2.7/dist-packages/cubicweb/server/sources/rql2sql.py, line 834, function select_sql
  needalias or needwrap)
File /usr/lib/python2.7/dist-packages/cubicweb/server/sources/rql2sql.py, line 914, function _solutions_sql
  self._state.merge_source_cbs(self._state._needs_source_cb)
File /usr/lib/python2.7/dist-packages/cubicweb/server/sources/rql2sql.py, line 385, function merge_source_cbs
  raise QueryError('query fetch some source mapped attribute, some not')
prioritynormal
typebug
done in<not specified>
closed by<not specified>