﻿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
33875	Inserting new record into partitioned table with triggers fails on returned values.	David Peall	nobody	"I have a PostgreSQL database with partitioned tables using inheritance and a trigger on the parent to insert into the correct child table.  The trigger returns null to prevent the record from also getting inserted into the parent table.

When using Django for these tables the model.save function would fail and the solution was to use the bulk save option.  However in newer versions of Django I am getting the same issue using the bulk save.
 
Using Model.objects.bulk_create([Model Object])

:     Message.objects.bulk_create([message])
:   File ""/usr/local/lib/python3.8/site-packages/django/db/models/manager.py"", line 85, in manager_method
:     return getattr(self.get_queryset(), name)(*args, * *kwargs)
:   File ""/usr/local/lib/python3.8/site-packages/django/db/models/query.py"", line 520, in bulk_create
:     for result, field in zip(results, opts.db_returning_fields):
: TypeError: 'NoneType' object is not iterable

Using Model.save()

:     message.save()
:   File ""/usr/local/lib/python3.8/site-packages/django/db/models/base.py"", line 745, in save
:     self.save_base(using=using, force_insert=force_insert,
:   File ""/usr/local/lib/python3.8/site-packages/django/db/models/base.py"", line 782, in save_base
:     updated = self._save_table(
:   File ""/usr/local/lib/python3.8/site-packages/django/db/models/base.py"", line 888, in _save_table
:     for result, field in zip(results, returning_fields):
: TypeError: 'NoneType' object is not iterable

For projects using SQL Alchemy I was able to resolve the issue using __table_args__ = {'implicit_returning': False} in the model, I could not find the same option for Django.
"	Bug	closed	Database layer (models, ORM)	3.2	Normal	invalid			Unreviewed	0	0	0	0	0	0
