Code

fixed searching on date / interval fields (sf bug 658157)
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Wed, 8 Jan 2003 05:39:40 +0000 (05:39 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Wed, 8 Jan 2003 05:39:40 +0000 (05:39 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1426 57a73879-2fb5-44c3-a270-3262357dd7e2

CHANGES.txt
roundup/backends/back_anydbm.py
roundup/backends/back_gadfly.py
roundup/backends/back_metakit.py
roundup/backends/rdbms_common.py

index 219c95bf30d689936db83a3c7f11cd4731bb285d..9a6ec697e120d644a478fb93e0aea0a02f818765 100644 (file)
@@ -14,6 +14,7 @@ are given with the most recent entry first.
 - better match for mailgw help "command" text
 - handle :add: better in cgi form parsing (sf bug 663235)
 - handle all-whitespace multilink values in forms (sf bug 663855)
+- fixed searching on date / interval fields (sf bug 658157)
 
 
 2002-12-11 0.5.3
index a199d1eb7629ba542998b22a6d5d7b2c9b824149..14b20f94ce14c34b309d69e4e7ff6c41e3df3e0d 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-#$Id: back_anydbm.py,v 1.95 2002-12-12 09:31:04 richard Exp $
+#$Id: back_anydbm.py,v 1.96 2003-01-08 05:39:40 richard Exp $
 '''
 This module defines a backend that saves the hyperdatabase in a database
 chosen by anydbm. It is guaranteed to always be available in python
@@ -1603,6 +1603,10 @@ class Class(hyperdb.Class):
                 else:
                     bv = v
                 l.append((OTHER, k, bv))
+            elif isinstance(propclass, Date):
+                l.append((OTHER, k, date.Date(v)))
+            elif isinstance(propclass, Interval):
+                l.append((OTHER, k, date.Interval(v)))
             elif isinstance(propclass, Number):
                 l.append((OTHER, k, int(v)))
             else:
index 1d25b5e90c90a3cec8557be4c8e7fcac5ec13518..da9347731813ab23fc9785ae768e3a6d2d0a8d6c 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: back_gadfly.py,v 1.30 2002-12-12 09:31:04 richard Exp $
+# $Id: back_gadfly.py,v 1.31 2003-01-08 05:39:40 richard Exp $
 ''' Gadlfy relational database hypderb backend.
 
 About Gadfly
@@ -169,6 +169,22 @@ class GadflyClass:
                 else:
                     where.append('id=%s.nodeid and %s.linkid = %s'%(tn, tn, a))
                     args.append(v)
+            elif isinstance(propclass, Date):
+                if isinstance(v, type([])):
+                    s = ','.join([a for x in v])
+                    where.append('_%s in (%s)'%(k, s))
+                    args = args + [date.Date(x).serialise() for x in v]
+                else:
+                    where.append('_%s=%s'%(k, a))
+                    args.append(date.Date(v).serialise())
+            elif isinstance(propclass, Interval):
+                if isinstance(v, type([])):
+                    s = ','.join([a for x in v])
+                    where.append('_%s in (%s)'%(k, s))
+                    args = args + [date.Interval(x).serialise() for x in v]
+                else:
+                    where.append('_%s=%s'%(k, a))
+                    args.append(date.Interval(v).serialise())
             else:
                 if isinstance(v, type([])):
                     s = ','.join([a for x in v])
index 6f940f79303226f2021315f84263037b48c22dae..48e0f4af22929a7f5eb0628f84d7e5751d2e72f1 100755 (executable)
@@ -813,6 +813,11 @@ class Class:
                 else:
                     bv = value
                 where[propname] = bv
+            elif isinstance(prop, hyperdb.Date):
+                t = date.Date(value).get_tuple()
+                where[propname] = int(calendar.timegm(t))
+            elif isinstance(prop, hyperdb.Interval):
+                where[propname] = str(date.Interval(value))
             elif isinstance(prop, hyperdb.Number):
                 where[propname] = int(value)
             else:
index 7c6ba76e4b80f5c95f402dc2ec647c6491a7c2b0..9df7a3e201c3d8d1053c550f133aeb953aa714dc 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: rdbms_common.py,v 1.26 2003-01-05 10:55:16 richard Exp $
+# $Id: rdbms_common.py,v 1.27 2003-01-08 05:39:40 richard Exp $
 ''' Relational database (SQL) backend common code.
 
 Basics:
@@ -1794,6 +1794,22 @@ class Class(hyperdb.Class):
                     else:
                         where.append('_%s=%s'%(k, a))
                         args.append(v)
+            elif isinstance(propclass, Date):
+                if isinstance(v, type([])):
+                    s = ','.join([a for x in v])
+                    where.append('_%s in (%s)'%(k, s))
+                    args = args + [date.Date(x).serialise() for x in v]
+                else:
+                    where.append('_%s=%s'%(k, a))
+                    args.append(date.Date(v).serialise())
+            elif isinstance(propclass, Interval):
+                if isinstance(v, type([])):
+                    s = ','.join([a for x in v])
+                    where.append('_%s in (%s)'%(k, s))
+                    args = args + [date.Interval(x).serialise() for x in v]
+                else:
+                    where.append('_%s=%s'%(k, a))
+                    args.append(date.Interval(v).serialise())
             else:
                 if isinstance(v, type([])):
                     s = ','.join([a for x in v])