Opened 6 years ago
Last modified 6 years ago
#30822 closed Bug
Oracle Bulk Create TextField fails when there is a mix of short and long string — at Version 2
| Reported by: | Ahmet Kucuk | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 2.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Georgi Yanchev | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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)
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.
Change History (2)
comment:1 by , 6 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 6 years ago
| Description: | modified (diff) |
|---|
Note:
See TracTickets
for help on using tickets.