Skip to content

Commit d35b278

Browse files
author
Richard Jones
committed
fixed searching on date / interval fields [SF#658157]
1 parent bae3701 commit d35b278

File tree

5 files changed

+45
-3
lines changed

5 files changed

+45
-3
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ are given with the most recent entry first.
1414
- better match for mailgw help "command" text
1515
- handle :add: better in cgi form parsing (sf bug 663235)
1616
- handle all-whitespace multilink values in forms (sf bug 663855)
17+
- fixed searching on date / interval fields (sf bug 658157)
1718

1819

1920
2002-12-11 0.5.3

roundup/backends/back_anydbm.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.95 2002-12-12 09:31:04 richard Exp $
18+
#$Id: back_anydbm.py,v 1.96 2003-01-08 05:39:40 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -1603,6 +1603,10 @@ def filter(self, search_matches, filterspec, sort=(None,None),
16031603
else:
16041604
bv = v
16051605
l.append((OTHER, k, bv))
1606+
elif isinstance(propclass, Date):
1607+
l.append((OTHER, k, date.Date(v)))
1608+
elif isinstance(propclass, Interval):
1609+
l.append((OTHER, k, date.Interval(v)))
16061610
elif isinstance(propclass, Number):
16071611
l.append((OTHER, k, int(v)))
16081612
else:

roundup/backends/back_gadfly.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_gadfly.py,v 1.30 2002-12-12 09:31:04 richard Exp $
1+
# $Id: back_gadfly.py,v 1.31 2003-01-08 05:39:40 richard Exp $
22
''' Gadlfy relational database hypderb backend.
33
44
About Gadfly
@@ -169,6 +169,22 @@ def filter(self, search_matches, filterspec, sort=(None,None),
169169
else:
170170
where.append('id=%s.nodeid and %s.linkid = %s'%(tn, tn, a))
171171
args.append(v)
172+
elif isinstance(propclass, Date):
173+
if isinstance(v, type([])):
174+
s = ','.join([a for x in v])
175+
where.append('_%s in (%s)'%(k, s))
176+
args = args + [date.Date(x).serialise() for x in v]
177+
else:
178+
where.append('_%s=%s'%(k, a))
179+
args.append(date.Date(v).serialise())
180+
elif isinstance(propclass, Interval):
181+
if isinstance(v, type([])):
182+
s = ','.join([a for x in v])
183+
where.append('_%s in (%s)'%(k, s))
184+
args = args + [date.Interval(x).serialise() for x in v]
185+
else:
186+
where.append('_%s=%s'%(k, a))
187+
args.append(date.Interval(v).serialise())
172188
else:
173189
if isinstance(v, type([])):
174190
s = ','.join([a for x in v])

roundup/backends/back_metakit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,11 @@ def filter(self, search_matches, filterspec, sort=(None,None),
813813
else:
814814
bv = value
815815
where[propname] = bv
816+
elif isinstance(prop, hyperdb.Date):
817+
t = date.Date(value).get_tuple()
818+
where[propname] = int(calendar.timegm(t))
819+
elif isinstance(prop, hyperdb.Interval):
820+
where[propname] = str(date.Interval(value))
816821
elif isinstance(prop, hyperdb.Number):
817822
where[propname] = int(value)
818823
else:

roundup/backends/rdbms_common.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.26 2003-01-05 10:55:16 richard Exp $
1+
# $Id: rdbms_common.py,v 1.27 2003-01-08 05:39:40 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -1794,6 +1794,22 @@ def filter(self, search_matches, filterspec, sort=(None,None),
17941794
else:
17951795
where.append('_%s=%s'%(k, a))
17961796
args.append(v)
1797+
elif isinstance(propclass, Date):
1798+
if isinstance(v, type([])):
1799+
s = ','.join([a for x in v])
1800+
where.append('_%s in (%s)'%(k, s))
1801+
args = args + [date.Date(x).serialise() for x in v]
1802+
else:
1803+
where.append('_%s=%s'%(k, a))
1804+
args.append(date.Date(v).serialise())
1805+
elif isinstance(propclass, Interval):
1806+
if isinstance(v, type([])):
1807+
s = ','.join([a for x in v])
1808+
where.append('_%s in (%s)'%(k, s))
1809+
args = args + [date.Interval(x).serialise() for x in v]
1810+
else:
1811+
where.append('_%s=%s'%(k, a))
1812+
args.append(date.Interval(v).serialise())
17971813
else:
17981814
if isinstance(v, type([])):
17991815
s = ','.join([a for x in v])

0 commit comments

Comments
 (0)