#30510: Bulk creates with Oracle backend fail with mixed length arguments on LOB
field
-------------------------------------+-------------------------------------
               Reporter:  Mark       |          Owner:  nobody
  Gordon                             |
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Database   |        Version:  2.1
  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          |
-------------------------------------+-------------------------------------
 Consider the below model, containing one LOB field


 {{{
 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 :arg1 col_0 FROM
 DUAL UNION ALL SELECT :arg0 FROM DUAL)`

 This works most of the time, however at some point logic was added to
 automatically convert a string's type to `Database.CLOB` when it exceeded
 4000 bytes from a normal string literal type. When this conversion happens
 for some of the arguments but not all of the arguments in the ephemeral
 table Oracle will complain that the type of the column of the unified
 table is inconsistent and fail the query.

 E.g. the following will fail

 {{{
 Bar.objects.bulk_create([Bar(baz='aaa'), Bar(baz='a'*5000)])
 }}}


 Generating the error

 `django.db.utils.DatabaseError: ORA-01790: expression must have same
 datatype as corresponding expression`

 Note that when both objects have a long or both have a short `baz` field
 this query succeeds.

 I'm working on a patch

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.8f9bcaa967cb443a848805cad76b3379%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to