﻿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
36289	Postgres bulk_create error when geometry is null or a different SRID	Joshua Goodwin	Simon Charette	"I have a model with a geometry field like this:

{{{
from django.contrib.gis.db import models

class Garage(models.Model):
    name = models.CharField(max_length=100, blank=True)
    location = models.PointField(null=True, blank=True)
}}}

With Django 5.2 and PostgreSQL (17.4 / PostGIS 3.5.2), {{{bulk_create}}} fails when I try to more than one item with a null location:

{{{
Garage.objects.bulk_create([Garage(), Garage()])
}}}


{{{
InternalError: parse error - invalid geometry
LINE 1: ...stimes_garage"" (""location"") SELECT * FROM UNNEST(('{NULL,NUL...
                                                             ^
HINT:  ""NU"" <-- parse error at position 2 within geometry
}}}

or with an SRID other than the default

{{{
Garage.objects.bulk_create([Garage(location=""SRID=29902;POINT(624210 307091)""), Garage(location=""SRID=29902;POINT(624210 307091)"")])
}}}

{{{
DataError: Geometry SRID (29902) does not match column SRID (4326)
}}}

This seems to be a regression in 5.2, maybe related to #35936 (Speeding up Postgres bulk_create by using unnest)"	Bug	closed	Database layer (models, ORM)	5.2	Release blocker	fixed		Simon Charette Mariusz Felisiak	Ready for checkin	1	0	0	0	0	0
