﻿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
17056	Creation of instances of a PK-only model fails under Oracle after introduction of bulk insert feature	Ramiro Morales	Ramiro Morales	"After r16739, trying to create an instance of this model:

{{{
from django.db import models

class Book(models.Model):
    pass
}}}

with:

{{{
>>> from django.test import TestCase
>>> from models import Book
>>> Book.objects.create()
}}}

generates an error like this when run against Oracle:

{{{
Traceback (most recent call last):
  File ""dtest/dtest01/store/tests.py"", line 9, in test_insert
    Book.objects.create()
  File ""django/upstream/django/db/models/manager.py"", line 137, in create
    return self.get_query_set().create(**kwargs)
  File ""django/upstream/django/db/models/query.py"", line 372, in create
    obj.save(force_insert=True, using=self.db)
  File ""django/upstream/django/db/models/base.py"", line 464, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File ""django/upstream/django/db/models/base.py"", line 551, in save_base
    result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
  File ""django/upstream/django/db/models/manager.py"", line 203, in _insert
    return insert_query(self.model, objs, fields, **kwargs)
  File ""django/upstream/django/db/models/query.py"", line 1556, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File ""django/upstream/django/db/models/sql/compiler.py"", line 848, in execute_sql
    cursor.execute(sql, params)
  File ""django/upstream/django/db/backends/oracle/base.py"", line 651, in execute
    query = convert_unicode(query % tuple(args), self.charset)
TypeError: not all arguments converted during string formatting
}}}

The compiler is generating the `""DEFAULT""` SQL keyword twice, once as part of the SQL query literal and once in the arguments tuple:

{{{
[
  (
    'INSERT INTO ""STORE_BOOK"" (""ID"") VALUES (DEFAULT) RETURNING ""STORE_BOOK"".""ID"" INTO %s',
    ('DEFAULT', <django.db.backends.oracle.base.InsertIdVar object at 0x912c0ac>)
  )
]
}}}

Currently, Django own test suite shows 80 errors of this type.
"	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed			Accepted	0	0	0	0	0	0
