Opened 3 years ago
Closed 3 years ago
#33339 closed Bug (fixed)
bulk_create() uses TO_CLOB() for NCLOB fields on Oracle.
Reported by: | Georgi Yanchev | Owned by: | Georgi Yanchev |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.2 |
Severity: | Normal | Keywords: | oracle |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
.
Change History (2)
comment:1 by , 3 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Has patch: | set |
Keywords: | oracle added |
Owner: | changed from | to
Status: | new → assigned |
Summary: | TO_CLOB is used for NCLOB fields in Oracle → bulk_create() uses TO_CLOB() for NCLOB fields on Oracle. |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
Note:
See TracTickets
for help on using tickets.
Thanks for the report.
PR