Roundup Tracker - Issues

Issue 1900918

classification
roundup.filter() gets confused by leap years
Type: Severity: normal
Components: Database Versions:
process
Status: closed fixed
:
: richard : nikratio, richard
Priority: normal :

Created on 2008-02-24 16:35 by nikratio, last changed 2008-08-18 06:41 by richard.

Messages
msg2528 Author: [hidden] (nikratio) Date: 2008-02-24 16:35
>>> db.issue.filter(None, { "due_date": "2008-02-29"})['1', '2', '3', '4', '5', '6', '7', 

etc.

>>> db.issue.get("1", "due_date")
<Date 2008-01-10.00:00:00.000>
>>> db.issue.get("2", "due_date")
>>> db.issue.get("3", "due_date")
<Date 2007-11-30.00:00:00.000>

Clearly something is wrong here. Other dates work just fine:

>>> db.issue.filter(None, { "due_date": "2008-02-28"})
['149']
>>> db.issue.get("149", "due_date")
<Date 2008-02-28.00:00:00.000>
>>> db.issue.filter(None, { "due_date": "2008-03-01"})
['222']
>>> db.issue.get("222", "due_date")
<Date 2008-03-01.00:00:00.000>
msg2529 Author: [hidden] (richard) Date: 2008-03-07 00:47
What version of Roundup and what backend are you using?

I'm having trouble reproducing the behaviour you're seeing. I've added a new test to the Roundup test suite and run it across all four backends with no errors:

    def testDateLeapYear(self):
        nid = self.db.issue.create(title='spam', status='1',
            deadline=date.Date('2008-02-29'))
        self.assertEquals(str(self.db.issue.get(nid, 'deadline')),
            '2008-02-29.00:00:00')
        self.db.issue.set(nid, deadline=date.Date('2008-02-29'))
        self.assertEquals(str(self.db.issue.get(nid, 'deadline')),
            '2008-02-29.00:00:00')
        self.assertEquals(self.db.issue.filter(None, {'deadline': '2008-02-29'}),
            [nid])

Could you please add this code to test/db_test_base.py (near testDateUnset) and run "python ./run_tests.py . testDateLeapYear"
msg2530 Author: [hidden] (nikratio) Date: 2008-03-16 10:28
I am using the SQLite backend. The roundup version is

> nikratio@ebox:~/stow$ bin/roundup-server --version
> 1.4.1 (python 2.4.4)

Since I did not keep the installation and test files, I downloaded roundup 1.4.4 
and run the test. That seems to work fine:

nikratio@ebox:~/roundup-1.4.4$ python ./run_tests.py . testDateLeapYear
Running unit tests at level 1

*** SOURCE WARNING: There are files missing (277/283 found)!
Missing: roundup-admin
Missing: roundup-demo
Missing: roundup-gettext
Missing: roundup-mailgw
Missing: roundup-server
Missing: roundup-xmlrpc-server
Running unit tests from /home/nikratio/roundup-1.4.4/.
Including anydbm tests
Skipping Xapian indexer tests
Skipping mysql tests
Skipping postgresql tests
Including sqlite tests
Skipping tsearch2 tests
testDateLeapYear (test.test_anydbm.anydbmDBTest) ... ok
testDateLeapYear (test.test_sqlite.sqliteDBTest) ... ok

----------------------------------------------------------------------
Ran 2 tests in 2.365s

OK


I therefore upgraded my installation to 1.4.4. Now I'm not able to reproduce the problem anymore.
msg2531 Author: [hidden] (nikratio) Date: 2008-03-16 15:28
Although the problem is fixed in 1.4.4, I just noticed that your testcase doesn't actually test for this bug. The problem was that all issues are returned, no matter what due date they have, if one searches for due_date Feb. 29. A correct testcase would be:

    def testDateLeapYear(self):
        nid = self.db.issue.create(title='spam', status='1',
            deadline=date.Date('2008-02-29'))
        self.assertEquals(str(self.db.issue.get(nid, 'deadline')),
            '2008-02-29.00:00:00')
        self.assertEquals(self.db.issue.filter(None, 
            {'deadline': '2008-02-29'}), [nid])
        self.db.issue.set(nid, deadline=date.Date('2008-03-01'))
        self.assertEquals(str(self.db.issue.get(nid, 'deadline')),
            '2008-03-01.00:00:00')
        self.assertEquals(self.db.issue.filter(None, 
            {'deadline': '2008-02-29'}), [])
msg2532 Author: [hidden] (richard) Date: 2008-08-18 06:41
Patched, finally, thanks.
History
Date User Action Args
2008-02-24 16:35:00nikratiocreate