[Django] #33339: TO_CLOB is used for NCLOB fields in Oracle

15 views
Skip to first unread message

Django

unread,
Dec 2, 2021, 6:22:32 PM12/2/21
to django-...@googlegroups.com
#33339: TO_CLOB is used for NCLOB fields in Oracle
------------------------------------------+------------------------
Reporter: Georgi Yanchev | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
Consider the model, containing one TextField


{{{
from django.db import models

class Bar(models.Model):
baz = models.TextField()
}}}

When you make a bulk_create request, e.g. Bar.objects.bulk_create([b0,
b1]) you will get generate a query like below.
{{{
INSERT INTO "PROJECT_BAR" ("BAZ") SELECT * FROM (SELECT TO_CLOB(:arg1)
col_0 FROM DUAL UNION ALL SELECT TO_CLOB(:arg0) FROM DUAL)
}}}

This will be accepted by Oracle, but it will create a log file, named
something like {{{DBNAME_ora_6613.trc}}}, which contains errors:

{{{
ORA-12704(1): dty=112 typ=1 flg=00220000 xfl=00040000 bfl=4000 bfc=0
csfm=2 csid=2000 csflg=0 collid=16382 cclvl=2
ORA-12704(2): dty=112 typ=2 flg=00230000 xfl=00000000 bfl=4000 bfc=0
csfm=1 csid=873 csflg=0 collid=16382 cclvl=3 op=184 opc=1
ORA-12704(2): dty=1 typ=3 flg=00030081 xfl=00040000 bfl=2000 bfc=2000
csfm=1 csid=873 csflg=0 collid=16382 cclvl=3 styp=1
}}}

The problem is that field {{{PROJECT_BAR.BAZ}}} is of type {{{NCLOB}}},
but Django uses {{{TO_CLOB}}}, instead of {{{TO_NCLOB}}}.

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

Django

unread,
Dec 3, 2021, 12:18:01 AM12/3/21
to django-...@googlegroups.com
#33339: bulk_create() uses TO_CLOB() for NCLOB fields on Oracle.
-------------------------------------+-------------------------------------
Reporter: Georgi Yanchev | Owner: Georgi
| Yanchev
Type: Bug | Status: assigned
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: oracle | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => assigned
* component: Uncategorized => Database layer (models, ORM)
* owner: nobody => Georgi Yanchev
* keywords: => oracle
* has_patch: 0 => 1
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

Thanks for the report.

[https://github.com/django/django/pull/15149 PR]

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

Django

unread,
Dec 3, 2021, 2:16:03 AM12/3/21
to django-...@googlegroups.com
#33339: bulk_create() uses TO_CLOB() for NCLOB fields on Oracle.
-------------------------------------+-------------------------------------
Reporter: Georgi Yanchev | Owner: Georgi
| Yanchev
Type: Bug | Status: closed

Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: oracle | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"9c1fe446b620963209df03b2fab1b3b9b5dc1988" 9c1fe446]:
{{{
#!CommitTicketReference repository=""
revision="9c1fe446b620963209df03b2fab1b3b9b5dc1988"
Fixed #33339 -- Made QuerySet.bulk_create() use TO_NCLOB() for TextFields
on Oracle.
}}}

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

Reply all
Reply to author
Forward
0 new messages