Commit 9de1da5e authored by Jérome Perrin's avatar Jérome Perrin

inventory_api: rely on catalog to add slot_index in the query

instead of implementing this logic in ZSQL's DTML
parent 14de13cd
...@@ -511,6 +511,14 @@ class SimulationTool(BaseTool): ...@@ -511,6 +511,14 @@ class SimulationTool(BaseTool):
# catalog # catalog
new_kw.pop('ignore_group_by', None) new_kw.pop('ignore_group_by', None)
# When group_by_time_sequence_list is used, the ZSQL method template
# will use a variable slot_index, we want to select it, group and order
# by it.
if sql_kw.get('group_by_time_sequence_list'):
new_kw['group_by_list'] = new_kw.get('group_by_list', []) + ['slot_index']
new_kw['order_by_list'] = new_kw.get('order_by_list', []) + [('slot_index', )]
new_kw.setdefault('select_dict', {})['slot_index'] = 'slot_index'
sql_kw.update(ctool.buildSQLQuery(**new_kw)) sql_kw.update(ctool.buildSQLQuery(**new_kw))
return sql_kw return sql_kw
......
...@@ -77,7 +77,6 @@ SELECT ...@@ -77,7 +77,6 @@ SELECT
COUNT(DISTINCT <dtml-var stock_table_id>.uid) AS stock_uid, COUNT(DISTINCT <dtml-var stock_table_id>.uid) AS stock_uid,
MAX(<dtml-var stock_table_id>.date) AS date MAX(<dtml-var stock_table_id>.date) AS date
</dtml-if> </dtml-if>
<dtml-if group_by_time_sequence_list>, slot_index </dtml-if> <dtml-comment>XXX is this really needed? are empty slots returned ? </dtml-comment>
<dtml-if select_expression>, <dtml-var select_expression></dtml-if> <dtml-if select_expression>, <dtml-var select_expression></dtml-if>
...@@ -188,16 +187,11 @@ WHERE ...@@ -188,16 +187,11 @@ WHERE
<dtml-if group_by_expression> <dtml-if group_by_expression>
GROUP BY GROUP BY
<dtml-if transformed_uid>transformation.transformed_uid,</dtml-if> <dtml-if transformed_uid>transformation.transformed_uid,</dtml-if>
<dtml-if group_by_time_sequence_list>slot_index,</dtml-if>
<dtml-var group_by_expression> <dtml-var group_by_expression>
</dtml-if> </dtml-if>
<dtml-if order_by_expression> <dtml-if order_by_expression>
ORDER BY ORDER BY
<dtml-var order_by_expression> <dtml-var order_by_expression>
<dtml-else>
<dtml-if group_by_time_sequence_list>
ORDER BY slot_index
</dtml-if>
</dtml-if> </dtml-if>
</dtml-let> </dtml-let>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment