Opened 9 months ago

Last modified 9 months ago

#22705 new Bug

can't bulk create models with no fields

Reported by: ellery-newcomer@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a model

class Discussion(models.Model): pass

I try to do this:

discussions = [Discussion() for i in range(n)]
Discussion.objects.bulk_create(discussions)

it fails with

AttributeError: 'NoneType' object has no attribute 'column'

because

django.db.models.sql.compiler.SQLInsertCompiler.as_sql has the following line in it:

fields = [None]

which doesn't get tripped on models that have fields, apparently.

Attachments (1)

22705-test.diff (1.2 KB) - added by timo 9 months ago.

Download all attachments as: .zip

Change History (2)

comment:1 Changed 9 months ago by timo

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

Can reproduce with the attached test for Django's test suite.

Changed 9 months ago by timo

Note: See TracTickets for help on using tickets.
Back to Top