[Django] #22144: Oralce Long text and bulk_create

23 views
Skip to first unread message

Django

unread,
Feb 25, 2014, 7:01:24 AM2/25/14
to django-...@googlegroups.com
#22144: Oralce Long text and bulk_create
----------------------------------------------+----------------------------
Reporter: artur@… | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer (models, ORM) | Version: 1.6
Severity: Normal | Keywords: oracle
Triage Stage: Unreviewed | bulk_create
Easy pickings: 0 | Has patch: 0
| UI/UX: 0
----------------------------------------------+----------------------------
I'm using django 1.6.2 + oracle 12 + cx_oracle 5.1.2

here is my model


{{{
class Value(models.Model):
text= models.TextField()
}}}

I have some text and it's length is 3000 characters in Russian language,
when im tring to do that:


{{{
text = 'some text' #3000 characters

v = Value(text=text)
v.save()
}}}

it's ok ...

but when i'm doing that:


{{{
text = 'some text' #3000 characters

v = Value(text=text)
Value.objects.bulk_create([v])
}}}

I got this exception:

{{{

Environment:


Request Method: GET
Request URL: http://127.0.0.1/test/

Django Version: 1.6.2
Python Version: 3.3.4
Installed Applications:
('django.contrib.admin',
'haystack',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'registration',
'modeltranslation',
'south',
'core',
'appl',
'legacy_data',
'djcelery')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'tpp.SiteUrlMiddleWare.SiteUrlMiddleWare',
'tpp.SiteUrlMiddleWare.GlobalRequest')


Traceback:
File "C:\Python33\lib\site-packages\django\core\handlers\base.py" in
get_response
114. response = wrapped_callback(request,
*callback_args, **callback_kwargs)
File "C:\Users\user\PycharmProjects\tpp\tppcenter\views.py" in test
374. Value.objects.bulk_create([v])
File "C:\Python33\lib\site-packages\django\db\models\manager.py" in
bulk_create
160. return self.get_queryset().bulk_create(*args, **kwargs)
File "C:\Python33\lib\site-packages\django\db\models\query.py" in
bulk_create
356. self._batched_insert(objs_without_pk, fields,
batch_size)
File "C:\Python33\lib\site-packages\django\db\models\query.py" in
_batched_insert
835. using=self.db)
File "C:\Python33\lib\site-packages\django\db\models\manager.py" in
_insert
232. return insert_query(self.model, objs, fields, **kwargs)
File "C:\Python33\lib\site-packages\django\db\models\query.py" in
insert_query
1511. return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Python33\lib\site-packages\django\db\models\sql\compiler.py" in
execute_sql
899. cursor.execute(sql, params)
File "C:\Python33\lib\site-packages\django\db\backends\util.py" in execute
69. return super(CursorDebugWrapper, self).execute(sql,
params)
File "C:\Python33\lib\site-packages\django\db\backends\util.py" in execute
53. return self.cursor.execute(sql, params)
File "C:\Python33\lib\site-packages\django\db\utils.py" in __exit__
99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Python33\lib\site-packages\django\utils\six.py" in reraise
535. raise value.with_traceback(tb)
File "C:\Python33\lib\site-packages\django\db\backends\util.py" in execute
53. return self.cursor.execute(sql, params)
File "C:\Python33\lib\site-packages\django\db\backends\oracle\base.py" in
execute
815. return self.cursor.execute(query,
self._param_generator(params))

Exception Type: DatabaseError at /test/
Exception Value: ORA-01461: can bind a LONG value only for insert into a
LONG column

}}}

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

Django

unread,
Feb 25, 2014, 7:22:26 AM2/25/14
to django-...@googlegroups.com
#22144: Oralce Long text and bulk_create
-------------------------------------+-------------------------------------

Reporter: artur@… | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 1.6
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: oracle bulk_create | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by artur@…):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Hmmm... I can insert larger rando text of 10k characters ...
But if I cut the text to 3000 ( my text is 2935 characters ) then I got
this exception ...

Seems like a bug in oracle segmentation algorithm when using bulk insert?

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

Django

unread,
Feb 25, 2014, 8:03:44 AM2/25/14
to django-...@googlegroups.com
#22144: Oracle Long text and bulk_create
-------------------------------------+-------------------------------------
Reporter: artur@… | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 1.6
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: oracle bulk_create | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by EvilDMP):

* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


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

Django

unread,
May 15, 2014, 5:53:23 AM5/15/14
to django-...@googlegroups.com
#22144: Oracle Long text and bulk_create
-------------------------------------+-------------------------------------
Reporter: artur@… | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: 1.6
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: oracle bulk_create | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by anonymous):

I get the same problem: my input is 2948 character long and fails with the
same error. As a workaround, I applied this ugly patch:
{{{
--- a/libs/project-packages/django/db/backends/oracle/base.py
+++ b/libs/project-packages/django/db/backends/oracle/base.py
@@ -616,7 +616,7 @@ class OracleParam(object):
if hasattr(param, 'input_size'):
# If parameter has `input_size` attribute, use that.
self.input_size = param.input_size
- elif isinstance(param, six.string_types) and len(param) > 4000:
+ elif isinstance(param, six.string_types) and len(param) > 2000:
# Mark any string param greater than 4000 characters as a
CLOB.
self.input_size = Database.CLOB
else:
}}}

My django version is 1.5.5.

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

Django

unread,
May 15, 2014, 6:07:41 AM5/15/14
to django-...@googlegroups.com
#22144: Oracle Long text and bulk_create
-------------------------------------+-------------------------------------
Reporter: artur@… | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: 1.6
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: oracle bulk_create | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by aurelien.scoubeau+trac@…):

Replying to [comment:3 myself] to give a name.

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

Django

unread,
Feb 23, 2017, 4:27:49 PM2/23/17
to django-...@googlegroups.com
#22144: Oracle Long text and bulk_create
-------------------------------------+-------------------------------------
Reporter: artur@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.6
(models, ORM) |
Severity: Normal | Resolution:
Keywords: oracle bulk_create | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* cc: felisiak.mariusz@… (added)


Comment:

I created simple test (in attachment) that fails on ''**stable/1.6.x**''
but passes properly on ''**stable/1.7.x**''. I didn't check that carefully
but probably it was fixed in
[https://github.com/django/django/commit/b7a67b788cf2fa59a84f933492413379eb3cab83
b7a67b78]. IMO we can resolve this ticket as fixed.

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

Django

unread,
Feb 23, 2017, 4:30:07 PM2/23/17
to django-...@googlegroups.com
#22144: Oracle Long text and bulk_create
-------------------------------------+-------------------------------------
Reporter: artur@… | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: 1.6
(models, ORM) |
Severity: Normal | Resolution:
Keywords: oracle bulk_create | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* Attachment "22144.diff" added.

Django

unread,
Feb 23, 2017, 8:47:14 PM2/23/17
to django-...@googlegroups.com
#22144: Oracle Long text and bulk_create
-------------------------------------+-------------------------------------
Reporter: artur@… | Owner: nobody
Type: Bug | Status: closed

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

Keywords: oracle bulk_create | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

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


Comment:

We could commit that test with a reference to this ticket if you think it
adds value.

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

Django

unread,
Feb 24, 2017, 2:08:16 AM2/24/17
to django-...@googlegroups.com
#22144: Oracle Long text and bulk_create
-------------------------------------+-------------------------------------
Reporter: artur@… | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version: 1.6
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: oracle bulk_create | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by felixxm):

I think it's worth doing ([https://github.com/django/django/pull/8109
PR]).

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

Django

unread,
Feb 24, 2017, 10:54:21 AM2/24/17
to django-...@googlegroups.com
#22144: Oracle Long text and bulk_create
-------------------------------------+-------------------------------------
Reporter: artur@… | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version: 1.6
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: oracle bulk_create | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"dc811cf50306972f838af8a975848ec26548bbf8" dc811cf5]:
{{{
#!CommitTicketReference repository=""
revision="dc811cf50306972f838af8a975848ec26548bbf8"
Refs #22144 -- Added test for QuerySet.bulk_create() with long non-ASCII
text.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22144#comment:8>

Reply all
Reply to author
Forward
0 new messages