Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#8510 closed (fixed)

Date filtering no longer works with integers

Reported by: jarrow Owned by: mtredinnick
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: boobsd@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Tested with r8507, on Debian Etch, sqlite and Python 2.4.4

======================================================================
FAIL: Doctest: modeltests.reserved_names.models.__test__.API_TESTS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for modeltests.reserved_names.models.__test__.API_TESTS
  File "/srv/lib/django-trunk/tests/modeltests/reserved_names/models.py", line unknown line number, in API_TESTS

----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/modeltests/reserved_names/models.py", line ?, in modeltests.reserved_names.models.__test__.API_TESTS
Failed example:
    Thing.objects.filter(where__month=1)
Expected:
    [<Thing: a>]
Got:
    []


======================================================================
FAIL: Doctest: modeltests.basic.models.__test__.API_TESTS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for modeltests.basic.models.__test__.API_TESTS
  File "/srv/lib/django-trunk/tests/modeltests/basic/models.py", line unknown line number, in API_TESTS

----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/modeltests/basic/models.py", line ?, in modeltests.basic.models.__test__.API_TESTS
Failed example:
    Article.objects.get(pub_date__year=2005, pub_date__month=7)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 1267, in __run
        compileflags, 1) in test.globs
      File "<doctest modeltests.basic.models.__test__.API_TESTS[14]>", line 1, in ?
        Article.objects.get(pub_date__year=2005, pub_date__month=7)
      File "/usr/lib/python2.4/site-packages/django/db/models/manager.py", line 81, in get
        return self.get_query_set().get(*args, **kwargs)
      File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 300, in get
        raise self.model.DoesNotExist("%s matching query does not exist."
    DoesNotExist: Article matching query does not exist.
----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/modeltests/basic/models.py", line ?, in modeltests.basic.models.__test__.API_TESTS
Failed example:
    Article.objects.get(pub_date__year=2005, pub_date__month=7, pub_date__day=28)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 1267, in __run
        compileflags, 1) in test.globs
      File "<doctest modeltests.basic.models.__test__.API_TESTS[15]>", line 1, in ?
        Article.objects.get(pub_date__year=2005, pub_date__month=7, pub_date__day=28)
      File "/usr/lib/python2.4/site-packages/django/db/models/manager.py", line 81, in get
        return self.get_query_set().get(*args, **kwargs)
      File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 300, in get
        raise self.model.DoesNotExist("%s matching query does not exist."
    DoesNotExist: Article matching query does not exist.
----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/modeltests/basic/models.py", line ?, in modeltests.basic.models.__test__.API_TESTS
Failed example:
    Article.objects.filter(pub_date__year=2005, pub_date__month=7)
Expected:
    [<Article: Area woman programs in Python>]
Got:
    []


======================================================================
FAIL: Doctest: regressiontests.model_regress.models.__test__.API_TESTS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for regressiontests.model_regress.models.__test__.API_TESTS
  File "/srv/lib/django-trunk/tests/regressiontests/model_regress/models.py", line unknown line number, in API_TESTS

----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/regressiontests/model_regress/models.py", line ?, in regressiontests.model_regress.models.__test__.API_TESTS
Failed example:
    [p.when for p in Party.objects.filter(when__month = 1)]
Expected:
    [datetime.date(1999, 1, 1)]
Got:
    []
----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/regressiontests/model_regress/models.py", line ?, in regressiontests.model_regress.models.__test__.API_TESTS
Failed example:
    [p.when for p in Party.objects.filter(when__month = 12)]
Expected:
    [datetime.date(1999, 12, 31), datetime.date(1998, 12, 31)]
Got:
    []


======================================================================
FAIL: Doctest: regressiontests.mail.tests
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for regressiontests.mail.tests
  File "/srv/lib/django-trunk/tests/regressiontests/mail/tests.py", line 1, in tests

----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/regressiontests/mail/tests.py", line 12, in regressiontests.mail.tests
Failed example:
    message['Subject']
Expected:
    <email.header.Header instance...>
Got:
    <email.Header.Header instance at 0x2aaaabbda710>
----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/regressiontests/mail/tests.py", line 27, in regressiontests.mail.tests
Failed example:
    message['Subject']
Expected:
    <email.header.Header instance...>
Got:
    <email.Header.Header instance at 0x2aaaabbe4290>


----------------------------------------------------------------------
Ran 449 tests in 303.805s

FAILED (failures=4)

Attachments (0)

Change History (13)

comment:1 Changed 6 years ago by jarrow

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Tests fail with r8507 to Tests fail after [8494]

comment:2 Changed 6 years ago by jarrow

Hmmm, some errors disappear below r8494 but this is still there with r8493:

======================================================================
FAIL: Doctest: regressiontests.mail.tests
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for regressiontests.mail.tests
  File "/srv/lib/django-trunk/tests/regressiontests/mail/tests.py", line 1, in tests

----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/regressiontests/mail/tests.py", line 12, in regressiontests.mail.tests
Failed example:
    message['Subject']
Expected:
    <email.header.Header instance...>
Got:
    <email.Header.Header instance at 0x2aaaabb365f0>
----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/regressiontests/mail/tests.py", line 27, in regressiontests.mail.tests
Failed example:
    message['Subject']
Expected:
    <email.header.Header instance...>
Got:
    <email.Header.Header instance at 0x2aaaabb04200>


----------------------------------------------------------------------
Ran 446 tests in 296.577s

FAILED (failures=1)

comment:3 Changed 6 years ago by jarrow

Ok, the last failure was triggered by [8483].

comment:4 Changed 6 years ago by jarrow

So [8494] actually triggered this (see below). And I opened another ticket for the other failure, see #8511.

======================================================================
FAIL: Doctest: modeltests.reserved_names.models.__test__.API_TESTS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for modeltests.reserved_names.models.__test__.API_TESTS
  File "/srv/lib/django-trunk/tests/modeltests/reserved_names/models.py", line unknown line number, in API_TESTS

----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/modeltests/reserved_names/models.py", line ?, in modeltests.reserved_names.models.__test__.API_TESTS
Failed example:
    Thing.objects.filter(where__month=1)
Expected:
    [<Thing: a>]
Got:
    []


======================================================================
FAIL: Doctest: modeltests.basic.models.__test__.API_TESTS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for modeltests.basic.models.__test__.API_TESTS
  File "/srv/lib/django-trunk/tests/modeltests/basic/models.py", line unknown line number, in API_TESTS

----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/modeltests/basic/models.py", line ?, in modeltests.basic.models.__test__.API_TESTS
Failed example:
    Article.objects.get(pub_date__year=2005, pub_date__month=7)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 1267, in __run
        compileflags, 1) in test.globs
      File "<doctest modeltests.basic.models.__test__.API_TESTS[14]>", line 1, in ?
        Article.objects.get(pub_date__year=2005, pub_date__month=7)
      File "/usr/lib/python2.4/site-packages/django/db/models/manager.py", line 81, in get
        return self.get_query_set().get(*args, **kwargs)
      File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 300, in get
        raise self.model.DoesNotExist("%s matching query does not exist."
    DoesNotExist: Article matching query does not exist.
----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/modeltests/basic/models.py", line ?, in modeltests.basic.models.__test__.API_TESTS
Failed example:
    Article.objects.get(pub_date__year=2005, pub_date__month=7, pub_date__day=28)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 1267, in __run
        compileflags, 1) in test.globs
      File "<doctest modeltests.basic.models.__test__.API_TESTS[15]>", line 1, in ?
        Article.objects.get(pub_date__year=2005, pub_date__month=7, pub_date__day=28)
      File "/usr/lib/python2.4/site-packages/django/db/models/manager.py", line 81, in get
        return self.get_query_set().get(*args, **kwargs)
      File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 300, in get
        raise self.model.DoesNotExist("%s matching query does not exist."
    DoesNotExist: Article matching query does not exist.
----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/modeltests/basic/models.py", line ?, in modeltests.basic.models.__test__.API_TESTS
Failed example:
    Article.objects.filter(pub_date__year=2005, pub_date__month=7)
Expected:
    [<Article: Area woman programs in Python>]
Got:
    []


======================================================================
FAIL: Doctest: regressiontests.model_regress.models.__test__.API_TESTS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for regressiontests.model_regress.models.__test__.API_TESTS
  File "/srv/lib/django-trunk/tests/regressiontests/model_regress/models.py", line unknown line number, in API_TESTS

----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/regressiontests/model_regress/models.py", line ?, in regressiontests.model_regress.models.__test__.API_TESTS
Failed example:
    [p.when for p in Party.objects.filter(when__month = 1)]
Expected:
    [datetime.date(1999, 1, 1)]
Got:
    []
----------------------------------------------------------------------
File "/srv/lib/django-trunk/tests/regressiontests/model_regress/models.py", line ?, in regressiontests.model_regress.models.__test__.API_TESTS
Failed example:
    [p.when for p in Party.objects.filter(when__month = 12)]
Expected:
    [datetime.date(1999, 12, 31), datetime.date(1998, 12, 31)]
Got:
    []

comment:5 Changed 6 years ago by Boo

  • Cc boobsd@… added

Yes, after [8494]

MyModel.objects.get(pub_date__month=11, pub_date__day=18, slug=blahblah)

return DoesNotExist exception, but before [8494] this works correct.

comment:6 Changed 6 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:7 follow-up: Changed 6 years ago by gsf

It appears that after [8494] month and day filtering work with strings but not integers, so the following returns the desired objects:

MyModel.objects.get(pub_date__month='11', pub_date__day='18')

comment:8 in reply to: ↑ 7 Changed 6 years ago by gsf

Replying to gsf:
With [8494] reverted, the query works with integers but not strings. Ideally, it would work with either.

comment:9 Changed 6 years ago by anonymous

  • Component changed from Uncategorized to Database wrapper

comment:10 Changed 6 years ago by mtredinnick

  • Summary changed from Tests fail after [8494] to Date filtering no longer works with integers

Both strings and integers should be valid there. It's not immediately clear why it's stopped working, but it is a bug.

Changing bug title to something more self-explanatory about the real problem.

comment:11 Changed 6 years ago by mtredinnick

  • Owner changed from nobody to mtredinnick
  • Status changed from new to assigned

comment:12 Changed 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [8526]) Fixed #8510 -- Allow both strings (mostly for the admin) and integers to be
used in "month" and "day" filters on date/datetime fields. Without this commit,
SQLite behaved inconsistently after [8494].

comment:13 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.