Opened 16 years ago

Closed 15 years ago

#11051 closed (fixed)

Oracle backend fails null_fk regression tests

Reported by: Matt Boersma Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: Oracle oracle
Cc: Erin Kelly, Jirka Vejrazka Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

These must be due to Oracle's nonstandard handling of NULL vs. empty string for VARCHAR columns.

C:\projects\django-trunk\tests>runtests.py --settings=testsettings.oracle null_fk
======================================================================
FAIL: Doctest: regressiontests.null_fk.models.__test__.API_TESTS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\django-trunk\django\test\_doctest.py", line 2180, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for regressiontests.null_fk.models.__test__.API_TESTS
  File "C:\projects\django-trunk\tests\regressiontests\null_fk\models.py", line unknown line number, in API_TESTS

----------------------------------------------------------------------
File "C:\projects\django-trunk\tests\regressiontests\null_fk\models.py", line ?, in regressiontests.null_fk.models.__test__.API_TESTS
Failed example:
    [(c.id, c.comment_text, c.post) for c in comments]
Exception raised:
    Traceback (most recent call last):
      File "C:\projects\django-trunk\django\test\_doctest.py", line 1267, in __run
        compileflags, 1) in test.globs
      File "<doctest regressiontests.null_fk.models.__test__.API_TESTS[10]>", line 1, in <module>
        [(c.id, c.comment_text, c.post) for c in comments]
      File "C:\projects\django-trunk\django\db\models\base.py", line 325, in __repr__
        u = unicode(self)
    TypeError: coercing to Unicode: need string or buffer, NoneType found
----------------------------------------------------------------------
File "C:\projects\django-trunk\tests\regressiontests\null_fk\models.py", line ?, in regressiontests.null_fk.models.__test__.API_TESTS
Failed example:
    Comment.objects.select_related('post').filter(post__isnull=True)[0].post is None
Expected:
    True
Got:
    False

This happens in the pre-1.1 trunk as of revision [10723]. It hasn't caused real-world problems as far as I know, but I've entered it here as a bug so we don't lose track of it.

Attachments (1)

oracle_null_fk_fix.diff (610 bytes ) - added by Jirka Vejrazka 15 years ago.

Download all attachments as: .zip

Change History (4)

by Jirka Vejrazka, 15 years ago

Attachment: oracle_null_fk_fix.diff added

comment:1 by Jirka Vejrazka, 15 years ago

Cc: Jirka Vejrazka added
Has patch: set
Resolution: fixed
Status: newclosed

I tried to track down this bug during the EuroDjangoCon sprint. Took a bit longer than expected (newbie tax :), but I found out that it only happened when specific fields were passed to select_related(). It was caused by Oracle backend's [browser:/django/trunk/django/db/backends/oracle/query.py?rev=10049#L41 resolve_columns()] returning fields as list, while this is expected to be a tuple later in [browser:/django/trunk/django/db/models/query.py?rev=10648#L952 get_cached_row()]

A simple modification to resolve_columns() fixed the problem, patch attached

comment:2 by Jirka Vejrazka, 15 years ago

Resolution: fixed
Status: closedreopened

Ehm, I guess I should leave this open until someone confirms :)

comment:3 by Matt Boersma, 15 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.
Back to Top