Skip to content

Commit 32e9c3a

Browse files
author
Richard Jones
committed
date spec wasn't allowing week intervals
1 parent e30a807 commit 32e9c3a

File tree

7 files changed

+30
-11
lines changed

7 files changed

+30
-11
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Fixed:
2323
- security check in mailgw (sf bug 1442145)
2424
- "clear this message" (sf bug 1429367)
2525
- escape all uses of "schema" in mysql backend (sf bug 1397569)
26+
- date spec wasn't allowing week intervals
2627

2728

2829
2006-02-10 1.1.0

roundup/backends/back_anydbm.py

Lines changed: 2 additions & 2 deletions
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.195 2006-02-06 21:00:46 richard Exp $
18+
#$Id: back_anydbm.py,v 1.196 2006-03-03 02:02:50 richard Exp $
1919
'''This module defines a backend that saves the hyperdatabase in a
2020
database chosen by anydbm. It is guaranteed to always be available in python
2121
versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -1591,7 +1591,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
15911591
l.append((STRING, k, re.compile(v, re.I)))
15921592
elif isinstance(propclass, hyperdb.Date):
15931593
try:
1594-
date_rng = propclass.range_from_raw (v, self.db)
1594+
date_rng = propclass.range_from_raw(v, self.db)
15951595
l.append((DATE, k, date_rng))
15961596
except ValueError:
15971597
# If range creation fails - ignore that search parameter

roundup/backends/rdbms_common.py

Lines changed: 2 additions & 2 deletions
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: rdbms_common.py,v 1.167 2006-02-09 23:53:11 richard Exp $
18+
#$Id: rdbms_common.py,v 1.168 2006-03-03 02:02:50 richard Exp $
1919
''' Relational database (SQL) backend common code.
2020
2121
Basics:
@@ -2130,7 +2130,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
21302130
else:
21312131
try:
21322132
# Try to filter on range of dates
2133-
date_rng = propclass.range_from_raw (v, self.db)
2133+
date_rng = propclass.range_from_raw(v, self.db)
21342134
if date_rng.from_value:
21352135
where.append('_%s._%s >= %s'%(cn, k, a))
21362136
args.append(dc(date_rng.from_value))

roundup/date.py

Lines changed: 2 additions & 2 deletions
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: date.py,v 1.83 2006-01-13 00:22:16 richard Exp $
18+
# $Id: date.py,v 1.84 2006-03-03 02:02:50 richard Exp $
1919

2020
"""Date, time and time interval handling.
2121
"""
@@ -46,7 +46,7 @@ def _add_granularity(src, order, value = 1):
4646
|(?P<a>\d\d?)[/-](?P<b>\d\d?))? # or mm-dd
4747
(?P<n>\.)? # .
4848
(((?P<H>\d?\d):(?P<M>\d\d))?(:(?P<S>\d\d(\.\d+)?))?)? # hh:mm:ss
49-
(?P<o>[\d\smyd\-+]+)? # offset
49+
(?P<o>[\d\smywd\-+]+)? # offset
5050
$''', re.VERBOSE)
5151
serialised_date_re = re.compile(r'''
5252
(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d?(\.\d+)?)

roundup/hyperdb.py

Lines changed: 3 additions & 3 deletions
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: hyperdb.py,v 1.117 2006-02-07 04:14:01 richard Exp $
18+
# $Id: hyperdb.py,v 1.118 2006-03-03 02:02:50 richard Exp $
1919

2020
"""Hyperdatabase implementation, especially field types.
2121
"""
@@ -83,9 +83,9 @@ def from_raw(self, value, db, **kw):
8383
raise HyperdbValueError, 'property %s: %r is an invalid '\
8484
'date (%s)'%(kw['propname'], value, message)
8585
return value
86-
def range_from_raw (self, value, db):
86+
def range_from_raw(self, value, db):
8787
"""return Range value from given raw value with offset correction"""
88-
return date.Range(value, date.Date, offset=self.offset (db))
88+
return date.Range(value, date.Date, offset=self.offset(db))
8989

9090
class Interval:
9191
"""An object designating an Interval property."""

test/db_test_base.py

Lines changed: 13 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: db_test_base.py,v 1.67 2006-02-09 23:53:11 richard Exp $
18+
# $Id: db_test_base.py,v 1.68 2006-03-03 02:02:50 richard Exp $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint, sets
2121

@@ -996,6 +996,7 @@ def testFilteringRange(self):
996996
# may fail :)
997997
ae(filt(None, {'deadline': 'from 2003-02-16'}), ['1', '3', '4'])
998998
ae(filt(None, {'deadline': '2003-02-16;'}), ['1', '3', '4'])
999+
ae(filt(None, {'deadline': '2003-02-16;'}), ['1', '3', '4'])
9991000
# year and month granularity
10001001
ae(filt(None, {'deadline': '2002'}), [])
10011002
ae(filt(None, {'deadline': '2003'}), ['1', '2', '3'])
@@ -1010,6 +1011,17 @@ def testFilteringRange(self):
10101011
ae(filt(None, {'foo': 'from 5:50'}), ['2'])
10111012
ae(filt(None, {'foo': 'to 0:05'}), [])
10121013

1014+
# further
1015+
for issue in (
1016+
{ 'deadline': date.Date('. -2d')},
1017+
{ 'deadline': date.Date('. -1d')},
1018+
{ 'deadline': date.Date('. -8d')},
1019+
):
1020+
self.db.issue.create(**issue)
1021+
ae(filt(None, {'deadline': '-2d;'}), ['5', '6'])
1022+
ae(filt(None, {'deadline': '-1d;'}), ['6'])
1023+
ae(filt(None, {'deadline': '-1w;'}), ['5', '6'])
1024+
10131025
def testFilteringIntervalSort(self):
10141026
# 1: '1:10'
10151027
# 2: '1d'

test/test_dates.py

Lines changed: 7 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: test_dates.py,v 1.37 2006-01-13 00:22:17 richard Exp $
18+
# $Id: test_dates.py,v 1.38 2006-03-03 02:02:50 richard Exp $
1919
from __future__ import nested_scopes
2020

2121
import unittest, time
@@ -84,6 +84,12 @@ def testOffset(self):
8484
date = Date("8:47:11", -5)
8585
ae(str(date), '%s-%02d-%02d.13:47:11'%(y, m, d))
8686

87+
# just make sure we parse these, m'kay?
88+
date = Date('-1d')
89+
date = Date('-1w')
90+
date = Date('-1m')
91+
date = Date('-1y')
92+
8793
def testOffsetRandom(self):
8894
ae = self.assertEqual
8995
# XXX unsure of the usefulness of these, they're pretty random

0 commit comments

Comments
 (0)