#28341: GeometryField doesn't create GEOSGeometry objects lazily anymore
-------------------------------------+-------------------------------------
     Reporter:  Sergey Fedoseev      |                    Owner:  Abhimanyu
                                     |  Singh Negi
         Type:  Bug                  |                   Status:  assigned
    Component:  GIS                  |                  Version:  1.8
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Abhimanyu Singh Negi):

 * owner:  (none) => Abhimanyu Singh Negi

Comment:

 Hi, I spent some time digging into this and I think I understand what’s
 going on.

 Right now geometry objects are being created too early. The conversion
 happens in the database converter layer —
 BaseSpatialOperations.get_db_converters() adds a geometry converter, and
 that converter runs in SQLCompiler.apply_converters(). So GEOSGeometry
 gets created while rows are being fetched, before the values ever reach
 the model instance. Because of that, SpatialProxy never sees raw values
 and the lazy-loading path isn’t used.

 I traced this through the ORM flow and confirmed that model instances
 already contain GEOSGeometry objects in instance.__dict__, which explains
 why accessing the field later doesn’t trigger any conversion.

 One important detail is that values() and values_list() depend on
 converters returning geometry objects immediately, so converters can’t
 just be removed. The fix needs to keep eager conversion for those cases
 but allow raw values when loading model instances so SpatialProxy can do
 the conversion lazily.

 I’m going to try implementing this by adjusting the geometry converter /
 registration logic so conversion is skipped when loading model instances,
 then add a regression test and run the GIS test suite to make sure nothing
 else breaks.

 Assigning this issue to myself for implementation.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/28341#comment:9>
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/0107019c5138e265-0ad11cc1-200a-4677-a4c2-7ac75a6dd481-000000%40eu-central-1.amazonses.com.

Reply via email to