﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30510	bulk_create() crashes with mixed length arguments on LOB fields on Oracle.	Mark Gordon	Ahmet Kucuk	"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"	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed	oracle bulk_create	Georgi Yanchev	Accepted	1	0	0	0	0	0
