Opened 6 years ago

Closed 6 years ago

#11051 closed (fixed)

Oracle backend fails null_fk regression tests

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

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 JirkaV 6 years ago.

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by JirkaV

comment:1 Changed 6 years ago by JirkaV

  • Cc JirkaV added
  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

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 Changed 6 years ago by JirkaV

  • Resolution fixed deleted
  • Status changed from closed to reopened

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

comment:3 Changed 6 years ago by mboersma

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.
Back to Top