[Django] #24307: Oracle Syncdb breaks trying to set NULL to column that already is NULL

22 views
Skip to first unread message

Django

unread,
Feb 9, 2015, 3:13:29 AM2/9/15
to django-...@googlegroups.com
#24307: Oracle Syncdb breaks trying to set NULL to column that already is NULL
----------------------------------------------+-----------------------
Reporter: JorisBenschop | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.8alpha1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+-----------------------
hi

I'm not sure if this is a dev question. Probably I did something dumb, so
I hope you can help me discover what that is:

I'm trying to syncdb to an empty Oracle DB. Many tables, triggers and
sequences are made but then this:
{{{
...
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying contenttypes.0002_remove_content_type_name...DEBUG ALTER TABLE
"DJANGO_CONTENT_TYPE" MODIFY "NAME" NULL; (params [])
DEBUG (0.055) QUERY = u'ALTER TABLE "DJANGO_CONTENT_TYPE" MODIFY "NAME"
NULL' - PARAMS = (); args=[]
Traceback (most recent call last):
...
...
django.db.utils.DatabaseError: ORA-01451: column to be modified to NULL
cannot be modified to NULL
}}}

Indeed if I run this in oracle directly:
{{{
ALTER TABLE "DJANGO_CONTENT_TYPE" MODIFY "NAME" NULL;
}}}
I get the same error: you cannot change a NULL column into NULL

I don't understand why django wants to alter a column name of a table it
just made a few seconds before, but still. What seems to happen is that it
changes a column to NULL, but because it already is NULL, the statement
fails.
Workaround is to manually set:
{{{
ALTER TABLE "DJANGO_CONTENT_TYPE" MODIFY ("NAME" NOT NULL);
}}}
Then run syncdb again and the error is gone.

I can see this is sillyness of oracle, but there's not much I can do about
that. Is this a bug?

--
Ticket URL: <https://code.djangoproject.com/ticket/24307>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 12, 2015, 3:19:09 PM2/12/15
to django-...@googlegroups.com
#24307: Oracle Syncdb breaks trying to set NULL to column that already is NULL
-------------------------------------+-------------------------------------

Reporter: JorisBenschop | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.8alpha1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: oracle 1.8-beta | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* keywords: => oracle 1.8-beta
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Not sure offhand, what version of Oracle (in case it matters)? I'll try to
make sure someone investigates this issue before 1.8 beta.

--
Ticket URL: <https://code.djangoproject.com/ticket/24307#comment:1>

Django

unread,
Feb 17, 2015, 2:43:02 PM2/17/15
to django-...@googlegroups.com
#24307: Oracle Syncdb breaks trying to set NULL to column that already is NULL
-------------------------------------+-------------------------------------

Reporter: JorisBenschop | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.8alpha1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: oracle 1.8-beta | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by JorisBenschop):

Its Oracle 11g afaik. I'm not close enough to the DBA to find out easily,
but if this is a requirement I can send in an internal request.

--
Ticket URL: <https://code.djangoproject.com/ticket/24307#comment:2>

Django

unread,
Feb 17, 2015, 5:05:49 PM2/17/15
to django-...@googlegroups.com
#24307: Oracle Syncdb breaks trying to set NULL to column that already is NULL
-------------------------------------+-------------------------------------
Reporter: JorisBenschop | Owner: shaib
Type: Bug | Status: assigned

Component: Database layer | Version: 1.8alpha1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: oracle 1.8-beta | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by shaib):

* owner: nobody => shaib
* status: new => assigned
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

It's a bug, I can easily reproduce it by just trying to migrate the
default project (created by `start_project`, with no changes except for
defining an Oracle database).

It happens, as the reporter said, because of Oracle silliness: On Oracle,
all `CharField`s are defined (in the database) null, because Oracle can't
tell the difference between null and an empty string. For Django 1.8, a
migration explicitly makes the `name` field null (it wasn't null before at
the Python level, nor on any other backend), and hence the failure.

--
Ticket URL: <https://code.djangoproject.com/ticket/24307#comment:3>

Django

unread,
Feb 17, 2015, 5:57:21 PM2/17/15
to django-...@googlegroups.com
#24307: Oracle Syncdb breaks trying to set NULL to column that already is NULL
-------------------------------------+-------------------------------------
Reporter: JorisBenschop | Owner: shaib
Type: Bug | Status: assigned
Component: Database layer | Version: 1.8alpha1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: oracle 1.8-beta | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by shaib):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/4162

--
Ticket URL: <https://code.djangoproject.com/ticket/24307#comment:4>

Django

unread,
Feb 17, 2015, 6:02:16 PM2/17/15
to django-...@googlegroups.com
#24307: Oracle Syncdb breaks trying to set NULL to column that already is NULL
-------------------------------------+-------------------------------------
Reporter: JorisBenschop | Owner: shaib
Type: Bug | Status: assigned
Component: Database layer | Version: 1.8alpha1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: oracle 1.8-beta | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by shaib):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

The patch fixes the problem reported in the ticket, but it As noted by
Tim on IRC, though, to detect such problems ourselves, we should make sure
the migrations for contrib apps are all run in the test-suite. Also
probably should test for the more specific problem explicitly.

--
Ticket URL: <https://code.djangoproject.com/ticket/24307#comment:5>

Django

unread,
Feb 18, 2015, 7:46:59 PM2/18/15
to django-...@googlegroups.com
#24307: Oracle Syncdb breaks trying to set NULL to column that already is NULL
-------------------------------------+-------------------------------------
Reporter: JorisBenschop | Owner: shaib
Type: Bug | Status: closed

Component: Database layer | Version: 1.8alpha1
(models, ORM) |
Severity: Release blocker | Resolution: fixed

Keywords: oracle 1.8-beta | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Shai Berger <shai@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"ceadc94f09f0615e95146f9a42b711acfc14f40f"]:
{{{
#!CommitTicketReference repository=""
revision="ceadc94f09f0615e95146f9a42b711acfc14f40f"
Fixed #24307: Avoided redundant column nullability modifications on Oracle

Thanks Joris Benschop for the report, and Tim Graham for the tests.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24307#comment:6>

Django

unread,
Feb 18, 2015, 7:47:19 PM2/18/15
to django-...@googlegroups.com
#24307: Oracle Syncdb breaks trying to set NULL to column that already is NULL
-------------------------------------+-------------------------------------
Reporter: JorisBenschop | Owner: shaib
Type: Bug | Status: closed
Component: Database layer | Version: 1.8alpha1
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: oracle 1.8-beta | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Shai Berger <shai@…>):

In [changeset:"66d37e593c8fa22be226b34b4fc1f60f85dcdc26"]:
{{{
#!CommitTicketReference repository=""
revision="66d37e593c8fa22be226b34b4fc1f60f85dcdc26"
[1.8.x] Fixed #24307: Avoided redundant column nullability modifications
on Oracle

Thanks Joris Benschop for the report, and Tim Graham for the tests.

Backport of ceadc94f09 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24307#comment:7>

Reply all
Reply to author
Forward
0 new messages