cubicweb #3278573 Error in Union in RQL [validation pending]
We have the following case:
But: rql('(Any Y ORDERBY ST_DISTANCE(G1, G2) ASC LIMIT 10 WHERE X geometry G1, X eid 102004034 , Y geometry G2) UNION (Any Z WHERE Z eid 102004034)') > 111211 The generated SQL is: SELECT _Y.cw_eid FROM cw_Location AS _X, cw_Location AS _Y WHERE _X.cw_eid=102004034 ORDER BY ST_DISTANCE(_X.cw_geometry, _Y.cw_geometry)) UNION ALL (SELECT 102004034) Simple testcase: (Any Y ORDERBY Y ASC LIMIT 10) UNION (Any Z WHERE Z eid 1)  
priority  minor 

type  bug 
done in  3.19.0 
load  1.000 
load left  0.000 
closed by  <not specified> 
Comments

2013/11/12 17:40, written by jcristau
add commentAfter some investigation...
The limit is dropped by server/ssplanner.py:OneFetchStep.set_limit_offset, which sets the limit of every element of the union to the limit from the last one. Handling this correctly in the sqlite case seems complicated, because as stated in http://www.sqlite.org/lang_select.html it only supports LIMIT for the whole statement, not for individual components of a UNION.
If you reverse your test case and say "(Any Z WHERE Z eid 1) UNION (Any Y ORDERBY Y ASC LIMIT 10)", you'll get a sql syntax error when running on sqlite, and the first component will have a "LIMIT 10" added.