From c969c2b33d4e186ba8d07dbd494832bd8b431115 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 28 Aug 2007 09:41:38 +0000
Subject: [PATCH] Make date constraint happen like any other column instead of
 making them a special case.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15863 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Tool/SimulationTool.py | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/product/ERP5/Tool/SimulationTool.py b/product/ERP5/Tool/SimulationTool.py
index f28227cf7b..5fb401fd7a 100644
--- a/product/ERP5/Tool/SimulationTool.py
+++ b/product/ERP5/Tool/SimulationTool.py
@@ -434,7 +434,7 @@ class SimulationTool(BaseTool):
       sql_kw['input'] = input
       sql_kw['output'] = output
 
-      query_list = []
+      column_value_dict = {}
 
       if omit_mirror_date:
         date_dict = {'query':[], 'operator':'and'}
@@ -454,17 +454,11 @@ class SimulationTool(BaseTool):
           date_dict['query'].append(at_date)
           date_dict['range'] = 'ngt'
         if len(date_dict) :
-          new_kw[table + '.date'] = date_dict
+          column_value_dict['date'] = date_dict
       else:
-        date_query_list = []
-        query_list.append(ComplexQuery(
-          Query(range='ngt', 
-                **{'%s.date' % table: [to_date]}),
-          Query(range='nlt', 
-                **{'%s.mirror_date' % table: [from_date]}),
-          operator='AND'))
+        column_value_dict['date'] = {'query': [to_date], 'range': 'ngt'}
+        column_value_dict['mirror_date'] = {'query': [from_date], 'range': 'nlt'}
 
-      column_value_dict = {}
       if resource_uid is not None :
         column_value_dict['resource_uid'] = resource_uid
       if section_uid is not None :
@@ -607,11 +601,7 @@ class SimulationTool(BaseTool):
         else:
           simulation_query = reserved_query
       if simulation_query is not None:
-        query_list.append(simulation_query)
-
-      if query_list:
-        new_kw['query'] = ComplexQuery(*query_list)
-
+        new_kw['query'] = simulation_query
 
       # It is necessary to use here another SQL query (or at least a subquery)
       # to get _DISTINCT_ uid from predicate_category table.
-- 
2.30.9