#36289: Postgres bulk_create error when geometry is null or a different SRID
-------------------------------------+-------------------------------------
     Reporter:  Joshua Goodwin       |                     Type:  Bug
       Status:  new                  |                Component:  Database
                                     |  layer (models, ORM)
      Version:  5.2                  |                 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 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)
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36289>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070195f853c6cb-5efb53c0-8c03-4dc4-9feb-6b26e78ecbf5-000000%40eu-central-1.amazonses.com.

Reply via email to