logilab-database #78916 sqlserver: ORDERBY + LIMIT fails if ORDERBY col is not selected [open]

rql("Any TSV ORDERBY RD LIMIT 1 DESC WHERE TSB eid 40152, TSB ts_variant TSV, TSV reference_date RD, TSV is_master True, TSV has_scenario A, A eid 3017, TSV reference_date <= '2011/05/31'")

exec WITH orderedrows AS (
SELECT
_L01
, ROW_NUMBER() OVER (ORDER BY _L01 DESC) AS __RowNumber
FROM (
SELECT _TSV.cw_eid AS _L01 FROM cw_TimeSeries AS _TSV, ts_variant_relation AS rel_ts_variant0
WHERE rel_ts_variant0.eid_from=40152 AND rel_ts_variant0.eid_to=_TSV.cw_eid AND
_TSV.cw_is_master=1 AND _TSV.cw_has_scenario=3017 AND _TSV.cw_reference_date<=%(124664544)s
) AS _SQ1 )
SELECT
_L01
FROM orderedrows WHERE
__RowNumber <= 1 {'124664544': u'2011/05/31'} <pyodbc.Connection object at 0x07057FC0>

-> ORDER BY clause in SQL on eid and not ref date.

priorityimportant
typebug
done in<not specified>
closed by<not specified>