﻿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
37506	"Oracle ""executemany()"" fails with mixed-length strings in Django 6.1.3, but works in Django 6.1.2"	pm13		"== Description ==

I encountered a regression after upgrading Django from 6.1.2 to 6.1.3.

I use `cursor.executemany()` to insert data into an Oracle table. One of the columns is defined as `VARCHAR2(8000)` and some values exceed 4000 characters.

The same code works with Django 6.1.2 but fails with Django 6.1.3.

== Environment ==

 * Django: 6.1.3 (works with 6.1.2)
 * python-oracledb: 26.1.0
 * Oracle database with `MAX_STRING_SIZE=EXTENDED`
 * Target column: `VARCHAR2(8000)`

== Steps to reproduce ==

Create a table:

{{{
CREATE TABLE django_lob_test (
    id NUMBER(10) NOT NULL PRIMARY KEY,
    text_value VARCHAR2(8000)
);
}}}

Run the following code using Django's database connection:

{{{#!python
from django.db import connection

small_text = ""s"" * 3500
large_text = ""L"" * 4199

rows = [
    [100, small_text],
    [101, large_text],
]

with connection.cursor() as cursor:
    cursor.executemany(
        ""INSERT INTO django_lob_test (id, text_value) VALUES (%s, %s)"",
        rows,
    )
}}}

== Actual results ==

With Django 6.1.3, the operation fails with:

{{{
oracledb.exceptions.NotSupportedError:
DPY-3013: unsupported Python type LOB for database type DB_TYPE_VARCHAR
}}}

Reversing the order of the rows produces a different error:

{{{
oracledb.exceptions.NotSupportedError:
DPY-3013: unsupported Python type str for database type DB_TYPE_CLOB
}}}

== Additional tests ==

I also tested the same inserts using the native python-oracledb cursor:

{{{#!python
raw_cursor = connection.connection.cursor()

raw_cursor.executemany(
    ""INSERT INTO django_lob_test (id, text_value) VALUES (:1, :2)"",
    rows,
)

raw_cursor.close()
}}}

Both row orders work successfully with the native cursor:

 * Short string first, long string second: SUCCESS
 * Long string first, short string second: SUCCESS

The issue does not occur with Django 6.1.2.

== Possible relation to #37411 ==

I noticed that Django 6.1.3 includes the fix for [https://code.djangoproject.com/ticket/37411 #37411 – Add support for python-oracledb version 26].

Looking at the changes in that ticket, I noticed that `OracleParam` now converts strings longer than 4000 bytes into temporary LOB objects using `cursor.connection.createlob()`.

I wonder if this change could be related to the issue, as the batch appears to contain a mixture of regular Python strings and LOB objects. I have not investigated the Django implementation in enough detail to confirm this, but thought it might be a useful starting point."	Bug	new	Database layer (models, ORM)	6.1	Normal			pm13	Unreviewed	0	0	0	0	0	0
