[Django] #29304: Bulk Create bug in ORACLE

5 views
Skip to first unread message

Django

unread,
Apr 9, 2018, 10:36:55 AM4/9/18
to django-...@googlegroups.com
#29304: Bulk Create bug in ORACLE
-----------------------------------------+------------------------
Reporter: isergey | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
I have to models
{{{
class Record(models.Model):
id = models.CharField(primary_key=True, max_length=32)
original_id = models.TextField(max_length=2048, blank=True)
hash = models.CharField(max_length=32)
source = models.ForeignKey(Source, on_delete=models.CASCADE)
schema = models.CharField(max_length=32)
session_id = models.BigIntegerField(default=0)
create_date = models.DateTimeField(db_index=True)
update_date = models.DateTimeField(db_index=True)
deleted = models.BooleanField(default=False, db_index=True)


class RecordContent(models.Model):
record = models.OneToOneField(Record, primary_key=True,
on_delete=models.CASCADE)
content = models.TextField(max_length=100 * 1024)
}}}
In MySQL this function works fine:
{{{
def _create_records(record_containers):
records = []
record_contents = []
for record_container in record_containers:
records.append(record_container['record'])
record_contents.append(record_container['content'])

models.Record.objects.bulk_create(records)
models.RecordContent.objects.bulk_create(record_contents)
}}}
But in Oracle this code thows exception: ORA-01790: expression must have
same datatype as corresponding expression

If refactor the function _create_records:
{{{
def _create_records(record_containers):
for record_container in record_containers:
models.Record.objects.bulk_create([record_container['record']])
models.RecordContent.objects.bulk_create([record_container['content']])
}}}
there is no exception is thrown.

What happens?

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

Django

unread,
Apr 9, 2018, 10:37:52 AM4/9/18
to django-...@googlegroups.com
#29304: Bulk Create bug in ORACLE
-------------------------------+--------------------------------------

Reporter: isergey | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by isergey:

Old description:

New description:

I have to models
{{{
class Record(models.Model):

hash = models.CharField(max_length=32)
source = models.ForeignKey(Source, on_delete=models.CASCADE)

What happens?

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29304#comment:1>

Django

unread,
Apr 9, 2018, 10:39:05 AM4/9/18
to django-...@googlegroups.com
#29304: Bulk Create bug in ORACLE
-------------------------------+--------------------------------------

Reporter: isergey | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by isergey:

Old description:

> I have to models
> {{{
> class Record(models.Model):


> hash = models.CharField(max_length=32)
> source = models.ForeignKey(Source, on_delete=models.CASCADE)

New description:

I have to models
{{{
class Record(models.Model):

hash = models.CharField(max_length=32)
source = models.ForeignKey(Source, on_delete=models.CASCADE)

create_date = models.DateTimeField(db_index=True)
update_date = models.DateTimeField(db_index=True)
deleted = models.BooleanField(default=False, db_index=True)


class RecordContent(models.Model):
record = models.OneToOneField(Record, primary_key=True,
on_delete=models.CASCADE)
content = models.TextField(max_length=100 * 1024)
}}}
In MySQL this function works fine:
{{{
def _create_records(record_containers):
records = []
record_contents = []
for record_container in record_containers:
records.append(record_container['record'])
record_contents.append(record_container['content'])

models.Record.objects.bulk_create(records)
models.RecordContent.objects.bulk_create(record_contents) # in Oracle


ORA-01790: expression must have same datatype as corresponding expression
}}}
But in Oracle this code thows exception: ORA-01790: expression must have
same datatype as corresponding expression

If refactor the function _create_records:
{{{
def _create_records(record_containers):
for record_container in record_containers:
models.Record.objects.bulk_create([record_container['record']])
models.RecordContent.objects.bulk_create([record_container['content']])
}}}
there is no exception is thrown.

What happens?

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29304#comment:2>

Django

unread,
Apr 9, 2018, 11:38:36 AM4/9/18
to django-...@googlegroups.com
#29304: QuerySet.bulk_create() fails with "ORA-01790: expression must have same
datatype as corresponding expression"
-------------------------------------+-------------------------------------
Reporter: isergey | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* type: Uncategorized => Bug
* component: Uncategorized => Database layer (models, ORM)


Old description:

> I have to models
> {{{
> class Record(models.Model):

> hash = models.CharField(max_length=32)
> source = models.ForeignKey(Source, on_delete=models.CASCADE)

> create_date = models.DateTimeField(db_index=True)
> update_date = models.DateTimeField(db_index=True)
> deleted = models.BooleanField(default=False, db_index=True)
>

> class RecordContent(models.Model):
> record = models.OneToOneField(Record, primary_key=True,
> on_delete=models.CASCADE)
> content = models.TextField(max_length=100 * 1024)
> }}}
> In MySQL this function works fine:
> {{{
> def _create_records(record_containers):
> records = []
> record_contents = []
> for record_container in record_containers:
> records.append(record_container['record'])
> record_contents.append(record_container['content'])
>
> models.Record.objects.bulk_create(records)

> models.RecordContent.objects.bulk_create(record_contents) # in Oracle


> ORA-01790: expression must have same datatype as corresponding expression
> }}}
> But in Oracle this code thows exception: ORA-01790: expression must have
> same datatype as corresponding expression
>
> If refactor the function _create_records:
> {{{
> def _create_records(record_containers):
> for record_container in record_containers:
> models.Record.objects.bulk_create([record_container['record']])
> models.RecordContent.objects.bulk_create([record_container['content']])
> }}}
> there is no exception is thrown.
>
> What happens?

New description:

I have two models:
{{{
class Record(models.Model):


hash = models.CharField(max_length=32)
source = models.ForeignKey(Source, on_delete=models.CASCADE)

create_date = models.DateTimeField(db_index=True)
update_date = models.DateTimeField(db_index=True)
deleted = models.BooleanField(default=False, db_index=True)


class RecordContent(models.Model):
record = models.OneToOneField(Record, primary_key=True,
on_delete=models.CASCADE)
content = models.TextField(max_length=100 * 1024)
}}}
In MySQL this function works fine:
{{{
def _create_records(record_containers):
records = []
record_contents = []
for record_container in record_containers:
records.append(record_container['record'])
record_contents.append(record_container['content'])

models.Record.objects.bulk_create(records)
models.RecordContent.objects.bulk_create(record_contents) # in Oracle


ORA-01790: expression must have same datatype as corresponding expression
}}}
But in Oracle this code thows exception: ORA-01790: expression must have
same datatype as corresponding expression

If refactor the function _create_records:
{{{
def _create_records(record_containers):
for record_container in record_containers:
models.Record.objects.bulk_create([record_container['record']])
models.RecordContent.objects.bulk_create([record_container['content']])
}}}
there is no exception is thrown.

What happens?

--

Comment:

What version of Django are you using? It might be a duplicate of #22669
(fixed in Django 2.0). If not, please try to minimize the code to
reproduce the issue, including the data that causes the crash.

--
Ticket URL: <https://code.djangoproject.com/ticket/29304#comment:3>

Django

unread,
Apr 9, 2018, 1:03:45 PM4/9/18
to django-...@googlegroups.com
#29304: QuerySet.bulk_create() fails with "ORA-01790: expression must have same
datatype as corresponding expression"
-------------------------------------+-------------------------------------
Reporter: isergey | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* cc: felixxm (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29304#comment:4>

Django

unread,
Apr 11, 2018, 10:35:42 AM4/11/18
to django-...@googlegroups.com
#29304: QuerySet.bulk_create() fails with "ORA-01790: expression must have same
datatype as corresponding expression"
-------------------------------------+-------------------------------------
Reporter: isergey | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => duplicate


--
Ticket URL: <https://code.djangoproject.com/ticket/29304#comment:5>

Reply all
Reply to author
Forward
0 new messages