Commit f8792d88 authored by Jérome Perrin's avatar Jérome Perrin

avoid left join on section if a section is already filtered.

fix error in testInventoryAPI



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9797 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cc51c6d4
...@@ -268,6 +268,7 @@ class SimulationTool (BaseTool): ...@@ -268,6 +268,7 @@ class SimulationTool (BaseTool):
new_kw[table + '.resource_uid'] = resource_uid new_kw[table + '.resource_uid'] = resource_uid
if section_uid is not None : if section_uid is not None :
new_kw[table + '.section_uid'] = section_uid new_kw[table + '.section_uid'] = section_uid
sql_kw['section_filtered'] = 1
if node_uid is not None : if node_uid is not None :
new_kw[table + '.node_uid'] = node_uid new_kw[table + '.node_uid'] = node_uid
...@@ -290,6 +291,7 @@ class SimulationTool (BaseTool): ...@@ -290,6 +291,7 @@ class SimulationTool (BaseTool):
section_uid_list = self._generatePropertyUidList(section) section_uid_list = self._generatePropertyUidList(section)
if section_uid_list: if section_uid_list:
new_kw[table + '.section_uid'] = section_uid_list new_kw[table + '.section_uid'] = section_uid_list
sql_kw['section_filtered'] = 1
mirror_section_uid_list = self._generatePropertyUidList(mirror_section) mirror_section_uid_list = self._generatePropertyUidList(mirror_section)
if mirror_section_uid_list: if mirror_section_uid_list:
...@@ -322,6 +324,7 @@ class SimulationTool (BaseTool): ...@@ -322,6 +324,7 @@ class SimulationTool (BaseTool):
section_category_uid_list = self._generatePropertyUidList(section_category) section_category_uid_list = self._generatePropertyUidList(section_category)
if section_category_uid_list: if section_category_uid_list:
new_kw[table + '_section_category_uid'] = section_category_uid_list new_kw[table + '_section_category_uid'] = section_category_uid_list
sql_kw['section_filtered'] = 1
mirror_section_category_uid_list = self._generatePropertyUidList( mirror_section_category_uid_list = self._generatePropertyUidList(
mirror_section_category) mirror_section_category)
...@@ -353,6 +356,7 @@ class SimulationTool (BaseTool): ...@@ -353,6 +356,7 @@ class SimulationTool (BaseTool):
if section_category_strict_membership_uid_list: if section_category_strict_membership_uid_list:
new_kw[table + '_section_category_strict_membership_uid'] =\ new_kw[table + '_section_category_strict_membership_uid'] =\
section_category_strict_membership_uid_list section_category_strict_membership_uid_list
sql_kw['section_filtered'] = 1
mirror_section_category_strict_membership_uid_list =\ mirror_section_category_strict_membership_uid_list =\
self._generatePropertyUidList( self._generatePropertyUidList(
......
...@@ -101,6 +101,12 @@ ...@@ -101,6 +101,12 @@
</dictionary> </dictionary>
</value> </value>
</item> </item>
<item>
<key> <string>section_filtered</string> </key>
<value>
<dictionary/>
</value>
</item>
<item> <item>
<key> <string>selection_domain</string> </key> <key> <string>selection_domain</string> </key>
<value> <value>
...@@ -142,6 +148,7 @@ ...@@ -142,6 +148,7 @@
<string>omit_simulation</string> <string>omit_simulation</string>
<string>omit_input</string> <string>omit_input</string>
<string>omit_output</string> <string>omit_output</string>
<string>section_filtered</string>
<string>input_simulation_state</string> <string>input_simulation_state</string>
<string>output_simulation_state</string> <string>output_simulation_state</string>
<string>group_by_expression</string> <string>group_by_expression</string>
...@@ -177,6 +184,7 @@ standardize\r\n ...@@ -177,6 +184,7 @@ standardize\r\n
omit_simulation\r\n omit_simulation\r\n
omit_input\r\n omit_input\r\n
omit_output\r\n omit_output\r\n
section_filtered\r\n
input_simulation_state:list\r\n input_simulation_state:list\r\n
output_simulation_state:list\r\n output_simulation_state:list\r\n
group_by_expression</string> </value> group_by_expression</string> </value>
...@@ -236,7 +244,8 @@ SELECT\n ...@@ -236,7 +244,8 @@ SELECT\n
\n \n
FROM\n FROM\n
stock\n stock\n
LEFT JOIN catalog AS section ON (section.uid = stock.section_uid)\n <dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if>\n
JOIN catalog AS section ON (section.uid = stock.section_uid)\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
...@@ -366,7 +375,8 @@ SELECT\n ...@@ -366,7 +375,8 @@ SELECT\n
\n \n
FROM\n FROM\n
stock\n stock\n
LEFT JOIN catalog AS section ON (section.uid = stock.section_uid)\n <dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if>\n
JOIN catalog AS section ON (section.uid = stock.section_uid)\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
......
...@@ -109,6 +109,12 @@ ...@@ -109,6 +109,12 @@
</dictionary> </dictionary>
</value> </value>
</item> </item>
<item>
<key> <string>section_filtered</string> </key>
<value>
<dictionary/>
</value>
</item>
<item> <item>
<key> <string>selection_domain</string> </key> <key> <string>selection_domain</string> </key>
<value> <value>
...@@ -149,6 +155,7 @@ ...@@ -149,6 +155,7 @@
<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>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>
...@@ -184,6 +191,7 @@ selection_report\r\n ...@@ -184,6 +191,7 @@ selection_report\r\n
ignore_variation\r\n ignore_variation\r\n
standardize\r\n standardize\r\n
omit_simulation\r\n omit_simulation\r\n
section_filtered\r\n
omit_input\r\n omit_input\r\n
omit_output\r\n omit_output\r\n
input_simulation_state:list\r\n input_simulation_state:list\r\n
...@@ -247,7 +255,8 @@ SELECT\n ...@@ -247,7 +255,8 @@ SELECT\n
\n \n
FROM\n FROM\n
stock\n stock\n
LEFT JOIN catalog AS section ON (section.uid = stock.section_uid)\n <dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if> \n
JOIN catalog AS section ON (section.uid = stock.section_uid)\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
...@@ -384,7 +393,8 @@ SELECT\n ...@@ -384,7 +393,8 @@ SELECT\n
\n \n
FROM\n FROM\n
stock\n stock\n
LEFT JOIN catalog AS section ON (section.uid = stock.section_uid)\n <dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if> \n
JOIN catalog AS section ON (section.uid = stock.section_uid)\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
......
...@@ -113,6 +113,12 @@ ...@@ -113,6 +113,12 @@
</dictionary> </dictionary>
</value> </value>
</item> </item>
<item>
<key> <string>section_filtered</string> </key>
<value>
<dictionary/>
</value>
</item>
<item> <item>
<key> <string>selection_domain</string> </key> <key> <string>selection_domain</string> </key>
<value> <value>
...@@ -155,6 +161,7 @@ ...@@ -155,6 +161,7 @@
<string>omit_simulation</string> <string>omit_simulation</string>
<string>omit_input</string> <string>omit_input</string>
<string>omit_output</string> <string>omit_output</string>
<string>section_filtered</string>
<string>initial_running_total_quantity</string> <string>initial_running_total_quantity</string>
<string>initial_running_total_price</string> <string>initial_running_total_price</string>
<string>input_simulation_state</string> <string>input_simulation_state</string>
...@@ -601,6 +608,7 @@ standardize\r\n ...@@ -601,6 +608,7 @@ standardize\r\n
omit_simulation\r\n omit_simulation\r\n
omit_input\r\n omit_input\r\n
omit_output\r\n omit_output\r\n
section_filtered\r\n
initial_running_total_quantity\r\n initial_running_total_quantity\r\n
initial_running_total_price\r\n initial_running_total_price\r\n
input_simulation_state:list\r\n input_simulation_state:list\r\n
...@@ -646,7 +654,6 @@ output_simulation_state:list</string> </value> ...@@ -646,7 +654,6 @@ output_simulation_state:list</string> </value>
SET @running_total_quantity := <dtml-var initial_running_total_quantity>,\n SET @running_total_quantity := <dtml-var initial_running_total_quantity>,\n
@running_total_price := <dtml-var initial_running_total_price>;\n @running_total_price := <dtml-var initial_running_total_price>;\n
\n
<dtml-var sql_delimiter>\n <dtml-var sql_delimiter>\n
\n \n
SELECT \n SELECT \n
...@@ -676,7 +683,8 @@ SELECT\n ...@@ -676,7 +683,8 @@ SELECT\n
\n \n
FROM\n FROM\n
stock\n stock\n
LEFT JOIN catalog AS section ON (section.uid = stock.section_uid)\n <dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if> \n
JOIN catalog AS section ON (section.uid = stock.section_uid)\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
...@@ -798,7 +806,6 @@ ORDER BY\n ...@@ -798,7 +806,6 @@ ORDER BY\n
SET @running_total_quantity := <dtml-var initial_running_total_quantity>,\n SET @running_total_quantity := <dtml-var initial_running_total_quantity>,\n
@running_total_price := <dtml-var initial_running_total_price>;\n @running_total_price := <dtml-var initial_running_total_price>;\n
\n
<dtml-var sql_delimiter>\n <dtml-var sql_delimiter>\n
\n \n
SELECT \n SELECT \n
...@@ -828,7 +835,8 @@ SELECT\n ...@@ -828,7 +835,8 @@ SELECT\n
\n \n
FROM\n FROM\n
stock\n stock\n
LEFT JOIN catalog AS section ON (section.uid = stock.section_uid)\n <dtml-if section_filtered> INNER <dtml-else> LEFT </dtml-if> \n
JOIN catalog AS section ON (section.uid = stock.section_uid)\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
......
61 62
\ No newline at end of file \ No newline at end of file
...@@ -491,12 +491,13 @@ class TestMovementHistoryList(InventoryAPITestCase): ...@@ -491,12 +491,13 @@ class TestMovementHistoryList(InventoryAPITestCase):
"""Movement History List returns a sequence object""" """Movement History List returns a sequence object"""
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
mvt_history_list = getMovementHistoryList() mvt_history_list = getMovementHistoryList()
self.failUnless(str(mvt_history_list.__class__), self.assertEquals(str(mvt_history_list.__class__),
'Shared.DC.ZRDB.Results.Results') 'Shared.DC.ZRDB.Results.Results')
# default is an empty list # default is an empty list
self.assertEquals(0, len(mvt_history_list)) self.assertEquals(0, len(mvt_history_list))
def testMovementBothSides(self): def testMovementBothSides(self):
"""Movement History List returns movement from both sides"""
getMovementHistoryList = self.getSimulationTool().getMovementHistoryList getMovementHistoryList = self.getSimulationTool().getMovementHistoryList
self._makeMovement(quantity=100) self._makeMovement(quantity=100)
# we don't filter, so we have the same movement from both sides. # we don't filter, so we have the same movement from both sides.
......
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