Code

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#6666 closed (fixed)

Oracle test case failure

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

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 (0)

Change History (12)

comment:1 Changed 6 years ago by ikelly

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 6 years ago by jacob

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

comment:3 Changed 6 years ago 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.

comment:4 Changed 6 years ago 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?

comment:5 Changed 6 years ago by mtredinnick

  • Triage Stage changed from Unreviewed to Accepted

comment:6 Changed 6 years ago 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.

comment:7 Changed 6 years ago by ikelly

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

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

comment:8 Changed 6 years ago by Alex

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

comment:9 Changed 6 years ago 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.

comment:10 Changed 6 years ago by mtredinnick

Yeah, it'll just get merged.

comment:11 follow-up: Changed 6 years ago by shan <shan_triv@…>

is this fix available in latest patch?

comment:12 in reply to: ↑ 11 Changed 6 years ago 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 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.