[Django] #30822: Oracle Bulk Create TextField fails when there is a mix of short and long string

5 views
Skip to first unread message

Django

unread,
Sep 30, 2019, 5:57:32 PM9/30/19
to django-...@googlegroups.com
#30822: Oracle Bulk Create TextField fails when there is a mix of short and long
string
-------------------------------------+-------------------------------------
Reporter: Ahmet | Owner: nobody
Kucuk |
Type: Bug | Status: new
Component: Database | Version: 2.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Following test currently fails because oracle DB backend converts params
larger than 4000 to be CLOB.

{{{
class OracleTextFieldBulkCreateTests(TestCase):
@unittest.skipIf(connection.vendor != 'oracle', 'Only an oracle
issue')
def test_text_field_bulk_create(self):
m1 = ModelD(name=''.join(['a']*4001))
m2 = ModelD(name='a')
ModelD.objects.bulk_create([m1, m2])
}}}


{{{
DatabaseError: ORA-01790: expression must have same datatype as
corresponding expression
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "django/db/backends/oracle/base.py", line 510, in execute
return self.cursor.execute(query, self._param_generator(params))

DatabaseError: ORA-01790: expression must have same datatype as
corresponding expression
(10 additional frame(s) were not displayed)
...
File "job_queue/management/commands/worker.py", line 48, in __call__
return execute(sql, params, many, context)
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "django/db/backends/oracle/base.py", line 510, in execute
return self.cursor.execute(query, self._param_generator(params))
}}}

Adding TextField: TO_CLOB mapping to the following object seems to fix the
issue:
https://github.com/django/django/blob/c4e2fc5d9872c9a0c9c052a2e124f8a9b87de9b4/django/db/backends/oracle/utils.py#L34

I am planning to open a PR with the fix if this is an acceptable solution.

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

Django

unread,
Sep 30, 2019, 6:02:22 PM9/30/19
to django-...@googlegroups.com
#30822: Oracle Bulk Create TextField fails when there is a mix of short and long
string
-------------------------------------+-------------------------------------
Reporter: Ahmet Kucuk | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Ahmet Kucuk:

Old description:

New description:

Following test currently fails because oracle DB backend converts params
larger than 4000 to be CLOB.

{{{
class OracleTextFieldBulkCreateTests(TestCase):
@unittest.skipIf(connection.vendor != 'oracle', 'Only an oracle
issue')
def test_text_field_bulk_create(self):

m1 = ModelD(name='a'*4001))

--

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

Django

unread,
Sep 30, 2019, 6:02:43 PM9/30/19
to django-...@googlegroups.com
#30822: Oracle Bulk Create TextField fails when there is a mix of short and long
string
-------------------------------------+-------------------------------------
Reporter: Ahmet Kucuk | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Ahmet Kucuk:

Old description:

> Following test currently fails because oracle DB backend converts params


> larger than 4000 to be CLOB.
>
> {{{
> class OracleTextFieldBulkCreateTests(TestCase):
> @unittest.skipIf(connection.vendor != 'oracle', 'Only an oracle
> issue')
> def test_text_field_bulk_create(self):

> m1 = ModelD(name='a'*4001))

New description:

Following test currently fails because oracle DB backend converts params
larger than 4000 to be CLOB.

{{{
class OracleTextFieldBulkCreateTests(TestCase):
@unittest.skipIf(connection.vendor != 'oracle', 'Only an oracle
issue')
def test_text_field_bulk_create(self):

m1 = ModelD(name='a'*4001)

--

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

Django

unread,
Sep 30, 2019, 6:15:32 PM9/30/19
to django-...@googlegroups.com
#30822: Oracle Bulk Create TextField fails when there is a mix of short and long
string
-------------------------------------+-------------------------------------
Reporter: Ahmet Kucuk | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* cc: Georgi Yanchev (added)


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

Django

unread,
Oct 1, 2019, 12:21:19 AM10/1/19
to django-...@googlegroups.com
#30822: Oracle Bulk Create TextField fails when there is a mix of short and long
string.

-------------------------------------+-------------------------------------
Reporter: Ahmet Kucuk | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

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


Comment:

Thanks for this report, proposed solution sounds reasonable. Please create
a PR and reference to an original ticket #30510. I'll evaluate both
patches and choose one of them. I like your proposition because it's
minimal and looks sufficient for now. I hope that someday I will have time
to refactor `bulk_create()` on Oracle (see
[https://github.com/django/django/pull/11416#issuecomment-504340841
comment]) but this can take time.

Duplicate of #30510.

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

Reply all
Reply to author
Forward
0 new messages