Django

Code

Ticket #6666 (closed: fixed)

Opened 9 months ago

Last modified 8 months ago

Oracle test case failure

Reported by: ikelly Assigned to: ikelly
Milestone: Component: Database layer (models, ORM)
Version: SVN Keywords: oracle
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

[7150] introduced a test case that fails in Oracle. The traceback is:

File "/home/ikelly/projects/django.trunk/tests/regressiontests/datatypes/models.py", line ?, in regressiontests.datatypes.models.__test__.API_TESTS
Failed example:
    Donut.objects.filter(baked_date__year=2006)
Exception raised:
    Traceback (most recent call last):
      File "/home/ikelly/projects/django.trunk/django/test/_doctest.py", line 1267, in __run
        compileflags, 1) in test.globs
      File "<doctest regressiontests.datatypes.models.__test__.API_TESTS[25]>", line 1, in <module>
        Donut.objects.filter(baked_date__year=2006)
      File "/home/ikelly/projects/django.trunk/django/db/models/query.py", line 108, in __repr__
        return repr(self._get_data())
      File "/home/ikelly/projects/django.trunk/django/db/models/query.py", line 483, in _get_data
        self._result_cache = list(self.iterator())
      File "/home/ikelly/projects/django.trunk/django/db/backends/oracle/base.py", line 123, in iterator
        cursor.execute(full_query, params)
      File "/home/ikelly/projects/django.trunk/django/db/backends/oracle/base.py", line 506, in execute
        return Database.Cursor.execute(self, query, params)
    DatabaseError: ORA-01830: date format picture ends before converting entire input string

The generated query and bind parameters are:

SELECT "DATATYPES_DONUT"."ID", "DATATYPES_DONUT"."NAME", "DATATYPES_DONUT"."IS_FROSTED", "DATATYPES_DONUT"."HAS_SPRINKLES", "DATATYPES_DONUT"."BAKED_DATE", "DATATYPES_DONUT"."BAKED_TIME", "DATATYPES_DONUT"."CONSUMED_AT"
 FROM "DATATYPES_DONUT" WHERE ("DATATYPES_DONUT"."BAKED_DATE" BETWEEN :arg0 AND :arg1) ORDER BY "DATATYPES_DONUT"."CONSUMED_AT" ASC

('2007-01-01 00:00:00', '2007-12-31 23:59:59.999999')

Attachments

Change History

02/26/08 12:35:28 changed by ikelly

  • status changed from new to assigned.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

02/26/08 14:26:14 changed by jacob

Looks like this is because of the microseconds at the end of the second param, right?

02/26/08 14:52:15 changed by ikelly

Yes, that's what it looks like to me. I plan to take a closer look at this later; I just opened the ticket so I wouldn't forget about it.

02/26/08 16:49:24 changed by mtredinnick

Doesn't that mean the bug existed prior to that change as well. I can't see what's changed if the database engine isn't "sqlite3" in that patch. It previously read

return ['%s-01-01 00:00:00' % value, '%s-12-31 23:59:59.999999' % value]

which has the same structure. Can somebody explain what silly typo I've overlooked here?

02/26/08 16:49:33 changed by mtredinnick

  • stage changed from Unreviewed to Accepted.

02/26/08 17:07:03 changed by ikelly

Yeah, I don't think that [7150] introduced the bug. As far as I can see, the only reason the test case didn't fail before was that it didn't exist yet. It's strange, though, because there are other tests of year lookups that pass. I suspect this is probably an issue of DateField? versus DateTimeField?, and that it's probably trivial to fix, but I'll need to take a closer look.

03/17/08 14:31:43 changed by ikelly

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [7274]) Fixed #6666: Corrected a bind param formatting issue when performing 'year' lookups on DateFields? using Oracle.

03/17/08 14:33:35 changed by Alex

Does this still need to be fixed in qs-rf?

03/17/08 14:49:33 changed by ikelly

Not sure, but probably. I just tried tried running the test case in qs-rf and got an ImportError?:

  File "/home/ikelly/projects/django.qs-rf/django/db/backends/oracle/base.py", line 103, in query_set_class
    from django.db.models.query import EmptyResultSet, GET_ITERATOR_CHUNK_SIZE, quote_only_if_word
ImportError: cannot import name GET_ITERATOR_CHUNK_SIZE

AFAICT, the change I committed is entirely orthogonal to the changes in qs-rf, so there should be no trouble merging it in.

03/17/08 23:36:39 changed by mtredinnick

Yeah, it'll just get merged.

(follow-up: ↓ 12 ) 03/26/08 15:53:10 changed by shan <shan_triv@hotmail.com>

is this fix available in latest patch?

(in reply to: ↑ 11 ) 03/26/08 16:15:18 changed by ikelly

Replying to shan <shan_triv@hotmail.com>:

is this fix available in latest patch?

I'm not sure what patch you're referring to, but this fix has been in trunk since revision [7274], if that's what you mean.


Add/Change #6666 (Oracle test case failure)




Change Properties
Action