From: richard Date: Wed, 8 Jan 2003 05:39:40 +0000 (+0000) Subject: fixed searching on date / interval fields (sf bug 658157) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b1b53477f5a976fe6b462ebe10be9f87a8bacdc1;p=roundup.git fixed searching on date / interval fields (sf bug 658157) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1426 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 219c95b..9a6ec69 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index a199d1e..14b20f9 100644 --- a/roundup/backends/back_anydbm.py +++ b/roundup/backends/back_anydbm.py @@ -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: diff --git a/roundup/backends/back_gadfly.py b/roundup/backends/back_gadfly.py index 1d25b5e..da93477 100644 --- a/roundup/backends/back_gadfly.py +++ b/roundup/backends/back_gadfly.py @@ -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]) diff --git a/roundup/backends/back_metakit.py b/roundup/backends/back_metakit.py index 6f940f7..48e0f4a 100755 --- a/roundup/backends/back_metakit.py +++ b/roundup/backends/back_metakit.py @@ -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: diff --git a/roundup/backends/rdbms_common.py b/roundup/backends/rdbms_common.py index 7c6ba76..9df7a3e 100644 --- a/roundup/backends/rdbms_common.py +++ b/roundup/backends/rdbms_common.py @@ -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])