MCPcopy
hub / github.com/django/django / as_postgresql

Method as_postgresql

django/contrib/gis/db/models/functions.py:484–500  ·  view source on GitHub ↗
(self, compiler, connection, **extra_context)

Source from the content-addressed store, hash-verified

482 return super().as_sql(compiler, connection, **extra_context)
483
484 def as_postgresql(self, compiler, connection, **extra_context):
485 clone = self.copy()
486 function = None
487 if self.source_is_geography():
488 clone.source_expressions.append(Value(self.spheroid))
489 elif self.geo_field.geodetic(connection):
490 # Geometry fields with geodetic (lon/lat) coordinates need
491 # length_spheroid
492 function = connection.ops.spatial_function_name("LengthSpheroid")
493 clone.source_expressions.append(Value(self.geo_field.spheroid(connection)))
494 else:
495 dim = min(f.dim for f in self.get_source_fields() if f)
496 if dim > 2:
497 function = connection.ops.length3d
498 return super(Length, clone).as_sql(
499 compiler, connection, function=function, **extra_context
500 )
501
502 def as_sqlite(self, compiler, connection, **extra_context):
503 function = None

Callers

nothing calls this directly

Calls 9

ValueClass · 0.90
source_is_geographyMethod · 0.80
geodeticMethod · 0.80
spatial_function_nameMethod · 0.80
copyMethod · 0.45
appendMethod · 0.45
spheroidMethod · 0.45
get_source_fieldsMethod · 0.45
as_sqlMethod · 0.45

Tested by

no test coverage detected