Commit c71d134d authored by Vincent Pelletier's avatar Vincent Pelletier

Add explicit joins with catalog.

Add conditions around uneeded joins in Resource_zGetInventoryList in specific getXxxInventory case (ie, getXxxInventoryList is not optimised).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15526 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 134c1c24
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="SQL" module="Products.ZSQLMethods.SQL"/>
<string>Products.ZSQLMethods.SQL</string> <tuple/>
<string>SQL</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -164,23 +161,23 @@ ...@@ -164,23 +161,23 @@
<key> <string>_keys</string> </key> <key> <string>_keys</string> </key>
<value> <value>
<list> <list>
<string>from_table_list</string> <string>from_table_list</string>
<string>where_expression</string> <string>where_expression</string>
<string>order_by_expression</string> <string>order_by_expression</string>
<string>group_by_expression</string> <string>group_by_expression</string>
<string>selection_domain</string> <string>selection_domain</string>
<string>selection_report</string> <string>selection_report</string>
<string>ignore_variation</string> <string>ignore_variation</string>
<string>standardize</string> <string>standardize</string>
<string>omit_simulation</string> <string>omit_simulation</string>
<string>section_filtered</string> <string>section_filtered</string>
<string>omit_input</string> <string>omit_input</string>
<string>omit_output</string> <string>omit_output</string>
<string>input_simulation_state</string> <string>input_simulation_state</string>
<string>output_simulation_state</string> <string>output_simulation_state</string>
<string>precision</string> <string>precision</string>
<string>inventory_list</string> <string>inventory_list</string>
<string>statistic</string> <string>statistic</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -253,13 +250,13 @@ statistic</string> </value> ...@@ -253,13 +250,13 @@ statistic</string> </value>
<key> <string>src</string> </key> <key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
<dtml-let join_with_catalog="omit_simulation or inventory_list or statistic">\n
\n
SELECT\n SELECT\n
<dtml-if expr="precision is not None">\n <dtml-if expr="precision is not None">\n
SUM(ROUND(stock.quantity, <dtml-var precision>)) AS inventory,\n
SUM(ROUND(stock.quantity, <dtml-var precision>)) AS total_quantity,\n SUM(ROUND(stock.quantity, <dtml-var precision>)) AS total_quantity,\n
SUM(ROUND(stock.total_price, <dtml-var precision>)) AS total_price\n SUM(ROUND(stock.total_price, <dtml-var precision>)) AS total_price\n
<dtml-else>\n <dtml-else>\n
SUM(stock.quantity) AS inventory,\n
SUM(stock.quantity) AS total_quantity,\n SUM(stock.quantity) AS total_quantity,\n
SUM(stock.total_price) AS total_price\n SUM(stock.total_price) AS total_price\n
</dtml-if>\n </dtml-if>\n
...@@ -298,8 +295,10 @@ SELECT\n ...@@ -298,8 +295,10 @@ SELECT\n
\n \n
FROM\n FROM\n
stock\n stock\n
<dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if> \n <dtml-if join_with_catalog>\n
JOIN catalog AS section ON (section.uid = stock.section_uid)\n <dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if> JOIN catalog AS section ON (section.uid = stock.section_uid)\n
, catalog as node, catalog as resource, catalog as catalog\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 != \'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
...@@ -307,7 +306,6 @@ FROM\n ...@@ -307,7 +306,6 @@ FROM\n
</dtml-in>\n </dtml-in>\n
<dtml-if selection_domain>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"> </dtml-if>\n <dtml-if selection_domain>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"> </dtml-if>\n
<dtml-if selection_report>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"> </dtml-if>\n <dtml-if selection_report>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"> </dtml-if>\n
, catalog as node, catalog as resource\n
\n \n
WHERE\n WHERE\n
1 = 1\n 1 = 1\n
...@@ -315,11 +313,12 @@ WHERE\n ...@@ -315,11 +313,12 @@ WHERE\n
AND <dtml-var where_expression>\n AND <dtml-var where_expression>\n
</dtml-if>\n </dtml-if>\n
\n \n
<dtml-if join_with_catalog>\n
AND node.uid = stock.node_uid\n AND node.uid = stock.node_uid\n
AND resource.uid = stock.resource_uid\n AND resource.uid = stock.resource_uid\n
\n <dtml-if omit_simulation>\n
<dtml-if omit_simulation>\n AND catalog.portal_type != \'Simulation Movement\'\n
AND catalog.portal_type != \'Simulation Movement\'\n </dtml-if>\n
</dtml-if>\n </dtml-if>\n
\n \n
<dtml-if selection_domain>\n <dtml-if selection_domain>\n
...@@ -336,6 +335,7 @@ GROUP BY\n ...@@ -336,6 +335,7 @@ GROUP BY\n
ORDER BY\n ORDER BY\n
<dtml-var order_by_expression>\n <dtml-var order_by_expression>\n
</dtml-if>\n </dtml-if>\n
</dtml-let>\n
]]></string> </value> ]]></string> </value>
...@@ -345,9 +345,11 @@ ORDER BY\n ...@@ -345,9 +345,11 @@ ORDER BY\n
<value> <value>
<object> <object>
<klass> <klass>
<global name="SQL" module="Shared.DC.ZRDB.DA"/> <global name="__newobj__" module="copy_reg"/>
</klass> </klass>
<none/> <tuple>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
...@@ -374,13 +376,13 @@ ORDER BY\n ...@@ -374,13 +376,13 @@ ORDER BY\n
<key> <string>raw</string> </key> <key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
<dtml-let join_with_catalog="omit_simulation or inventory_list or statistic">\n
\n
SELECT\n SELECT\n
<dtml-if expr="precision is not None">\n <dtml-if expr="precision is not None">\n
SUM(ROUND(stock.quantity, <dtml-var precision>)) AS inventory,\n
SUM(ROUND(stock.quantity, <dtml-var precision>)) AS total_quantity,\n SUM(ROUND(stock.quantity, <dtml-var precision>)) AS total_quantity,\n
SUM(ROUND(stock.total_price, <dtml-var precision>)) AS total_price\n SUM(ROUND(stock.total_price, <dtml-var precision>)) AS total_price\n
<dtml-else>\n <dtml-else>\n
SUM(stock.quantity) AS inventory,\n
SUM(stock.quantity) AS total_quantity,\n SUM(stock.quantity) AS total_quantity,\n
SUM(stock.total_price) AS total_price\n SUM(stock.total_price) AS total_price\n
</dtml-if>\n </dtml-if>\n
...@@ -419,8 +421,10 @@ SELECT\n ...@@ -419,8 +421,10 @@ SELECT\n
\n \n
FROM\n FROM\n
stock\n stock\n
<dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if> \n <dtml-if join_with_catalog>\n
JOIN catalog AS section ON (section.uid = stock.section_uid)\n <dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if> JOIN catalog AS section ON (section.uid = stock.section_uid)\n
, catalog as node, catalog as resource, catalog as catalog\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 != \'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
...@@ -428,7 +432,6 @@ FROM\n ...@@ -428,7 +432,6 @@ FROM\n
</dtml-in>\n </dtml-in>\n
<dtml-if selection_domain>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"> </dtml-if>\n <dtml-if selection_domain>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"> </dtml-if>\n
<dtml-if selection_report>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"> </dtml-if>\n <dtml-if selection_report>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"> </dtml-if>\n
, catalog as node, catalog as resource\n
\n \n
WHERE\n WHERE\n
1 = 1\n 1 = 1\n
...@@ -436,11 +439,12 @@ WHERE\n ...@@ -436,11 +439,12 @@ WHERE\n
AND <dtml-var where_expression>\n AND <dtml-var where_expression>\n
</dtml-if>\n </dtml-if>\n
\n \n
<dtml-if join_with_catalog>\n
AND node.uid = stock.node_uid\n AND node.uid = stock.node_uid\n
AND resource.uid = stock.resource_uid\n AND resource.uid = stock.resource_uid\n
\n <dtml-if omit_simulation>\n
<dtml-if omit_simulation>\n AND catalog.portal_type != \'Simulation Movement\'\n
AND catalog.portal_type != \'Simulation Movement\'\n </dtml-if>\n
</dtml-if>\n </dtml-if>\n
\n \n
<dtml-if selection_domain>\n <dtml-if selection_domain>\n
...@@ -457,6 +461,7 @@ GROUP BY\n ...@@ -457,6 +461,7 @@ GROUP BY\n
ORDER BY\n ORDER BY\n
<dtml-var order_by_expression>\n <dtml-var order_by_expression>\n
</dtml-if>\n </dtml-if>\n
</dtml-let>\n
]]></string> </value> ]]></string> </value>
......
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="SQL" module="Products.ZSQLMethods.SQL"/>
<string>Products.ZSQLMethods.SQL</string> <tuple/>
<string>SQL</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -630,9 +627,7 @@ precision</string> </value> ...@@ -630,9 +627,7 @@ precision</string> </value>
</item> </item>
<item> <item>
<key> <string>connection_hook</string> </key> <key> <string>connection_hook</string> </key>
<value> <value> <string></string> </value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>connection_id</string> </key> <key> <string>connection_id</string> </key>
...@@ -699,7 +694,7 @@ FROM\n ...@@ -699,7 +694,7 @@ FROM\n
</dtml-in>\n </dtml-in>\n
<dtml-if selection_domain>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"> </dtml-if>\n <dtml-if selection_domain>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"> </dtml-if>\n
<dtml-if selection_report>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"> </dtml-if>\n <dtml-if selection_report>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"> </dtml-if>\n
, catalog as node, catalog as resource\n , catalog as node, catalog as resource, catalog as catalog\n
\n \n
WHERE\n WHERE\n
1 = 1\n 1 = 1\n
...@@ -709,6 +704,7 @@ WHERE\n ...@@ -709,6 +704,7 @@ WHERE\n
\n \n
AND node.uid = stock.node_uid\n AND node.uid = stock.node_uid\n
AND resource.uid = stock.resource_uid\n AND resource.uid = stock.resource_uid\n
AND catalog.uid = stock.uid\n
\n \n
<dtml-if omit_simulation>\n <dtml-if omit_simulation>\n
AND catalog.portal_type != \'Simulation Movement\'\n AND catalog.portal_type != \'Simulation Movement\'\n
...@@ -783,9 +779,11 @@ ORDER BY\n ...@@ -783,9 +779,11 @@ ORDER BY\n
<value> <value>
<object> <object>
<klass> <klass>
<global name="SQL" module="Shared.DC.ZRDB.DA"/> <global name="__newobj__" module="copy_reg"/>
</klass> </klass>
<none/> <tuple>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</tuple>
<state> <state>
<dictionary> <dictionary>
<item> <item>
...@@ -857,7 +855,7 @@ FROM\n ...@@ -857,7 +855,7 @@ FROM\n
</dtml-in>\n </dtml-in>\n
<dtml-if selection_domain>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"> </dtml-if>\n <dtml-if selection_domain>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_domain)"> </dtml-if>\n
<dtml-if selection_report>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"> </dtml-if>\n <dtml-if selection_report>, <dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)"> </dtml-if>\n
, catalog as node, catalog as resource\n , catalog as node, catalog as resource, catalog as catalog\n
\n \n
WHERE\n WHERE\n
1 = 1\n 1 = 1\n
...@@ -867,6 +865,7 @@ WHERE\n ...@@ -867,6 +865,7 @@ WHERE\n
\n \n
AND node.uid = stock.node_uid\n AND node.uid = stock.node_uid\n
AND resource.uid = stock.resource_uid\n AND resource.uid = stock.resource_uid\n
AND catalog.uid = stock.uid\n
\n \n
<dtml-if omit_simulation>\n <dtml-if omit_simulation>\n
AND catalog.portal_type != \'Simulation Movement\'\n AND catalog.portal_type != \'Simulation Movement\'\n
......
381 383
\ No newline at end of file \ No newline at end of file
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