Commit 7628f15e authored by Jérome Perrin's avatar Jérome Perrin

Inventory API: support left join queries

parent 861467c3
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<item> <item>
<key> <string>arguments_src</string> </key> <key> <string>arguments_src</string> </key>
<value> <string>from_table_list:list\r\n <value> <string>from_table_list:list\r\n
from_expression\r\n
where_expression\r\n where_expression\r\n
order_by_expression\r\n order_by_expression\r\n
group_by_expression\r\n group_by_expression\r\n
...@@ -142,17 +143,22 @@ SELECT\n ...@@ -142,17 +143,22 @@ SELECT\n
<dtml-if select_expression>, <dtml-var select_expression></dtml-if>\n <dtml-if select_expression>, <dtml-var select_expression></dtml-if>\n
\n \n
FROM\n FROM\n
catalog, <dtml-var stock_table_id>\n <dtml-if from_expression>\n
<dtml-if quantity_unit_uid>\n <dtml-var from_expression>\n
LEFT JOIN quantity_unit_conversion ON \n <dtml-else>\n
(quantity_unit_conversion.resource_uid = <dtml-var stock_table_id>.resource_uid\n catalog\n
AND quantity_unit_conversion.quantity_unit_uid = <dtml-sqlvar quantity_unit_uid type=int>)\n
</dtml-if>\n
<dtml-in prefix="table" expr="from_table_list"> \n <dtml-in prefix="table" expr="from_table_list"> \n
<dtml-if expr="table_key not in (\'catalog\', stock_table_id)">\n <dtml-if expr="table_key not in (\'catalog\', stock_table_id)">\n
, <dtml-var table_item> AS <dtml-var table_key>\n , <dtml-var table_item> AS <dtml-var table_key>\n
</dtml-if>\n </dtml-if>\n
</dtml-in>\n </dtml-in>\n
, <dtml-var stock_table_id>\n
</dtml-if>\n
<dtml-if quantity_unit_uid> <dtml-comment>XXX quantity unit conversion will not work when using implict_join=False</dtml-comment>\n
LEFT JOIN quantity_unit_conversion ON \n
(quantity_unit_conversion.resource_uid = <dtml-var stock_table_id>.resource_uid\n
AND quantity_unit_conversion.quantity_unit_uid = <dtml-sqlvar quantity_unit_uid type=int>)\n
</dtml-if>\n
<dtml-if selection_domain><dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain, category_table_alias=\'domain_category\')"><dtml-if expression>, <dtml-var expression></dtml-if></dtml-let></dtml-if>\n <dtml-if selection_domain><dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain, category_table_alias=\'domain_category\')"><dtml-if expression>, <dtml-var expression></dtml-if></dtml-let></dtml-if>\n
<dtml-if selection_report><dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report, category_table_alias=\'report_category\')"><dtml-if expression>, <dtml-var expression></dtml-if></dtml-let></dtml-if>\n <dtml-if selection_report><dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report, category_table_alias=\'report_category\')"><dtml-if expression>, <dtml-var expression></dtml-if></dtml-let></dtml-if>\n
<dtml-if transformed_uid>, transformation, catalog as transformed_resource</dtml-if>\n <dtml-if transformed_uid>, transformation, catalog as transformed_resource</dtml-if>\n
......
...@@ -417,7 +417,8 @@ ...@@ -417,7 +417,8 @@
</item> </item>
<item> <item>
<key> <string>arguments_src</string> </key> <key> <string>arguments_src</string> </key>
<value> <string>from_table_list:list\r\n <value> <string>from_expression\r\n
from_table_list:list\r\n
where_expression\r\n where_expression\r\n
order_by_expression\r\n order_by_expression\r\n
group_by_expression\r\n group_by_expression\r\n
...@@ -512,12 +513,16 @@ SELECT\n ...@@ -512,12 +513,16 @@ SELECT\n
stock.node_uid AS node_uid,\n stock.node_uid AS node_uid,\n
stock.section_uid AS section_uid\n stock.section_uid AS section_uid\n
FROM\n FROM\n
<dtml-if from_expression>\n
<dtml-var from_expression>\n
<dtml-else>\n
stock\n stock\n
<dtml-in prefix="table" expr="from_table_list"> \n <dtml-in prefix="table" expr="from_table_list"> \n
<dtml-if expr="table_key != \'stock\'">\n <dtml-if expr="table_key != \'stock\'">\n
, <dtml-var table_item> AS <dtml-var table_key>\n , <dtml-var table_item> AS <dtml-var table_key>\n
</dtml-if>\n </dtml-if>\n
</dtml-in>\n </dtml-in>\n
</dtml-if>\n
<dtml-if selection_domain><dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain, category_table_alias=\'domain_category\')"><dtml-if expression>, <dtml-var expression></dtml-if></dtml-let></dtml-if>\n <dtml-if selection_domain><dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain, category_table_alias=\'domain_category\')"><dtml-if expression>, <dtml-var expression></dtml-if></dtml-let></dtml-if>\n
<dtml-if selection_report><dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report, category_table_alias=\'report_category\')"><dtml-if expression>, <dtml-var expression></dtml-if></dtml-let></dtml-if>\n <dtml-if selection_report><dtml-let expression="portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report, category_table_alias=\'report_category\')"><dtml-if expression>, <dtml-var expression></dtml-if></dtml-let></dtml-if>\n
\n \n
......
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