Fixed #28632 -- Updated docs about using raw SQL with GIS and doc'd changes from refs #28518 in release notes.
This commit is contained in:
parent
69922d303d
commit
8869142a4d
|
@ -645,16 +645,21 @@ of abstraction::
|
|||
|
||||
__ http://spatialreference.org/ref/epsg/32140/
|
||||
|
||||
.. _gis-raw-sql:
|
||||
|
||||
.. admonition:: Raw queries
|
||||
|
||||
When using :doc:`raw queries </topics/db/sql>`, you should generally wrap
|
||||
your geometry fields with the ``asText()`` SQL function (or ``ST_AsText``
|
||||
for PostGIS) so that the field value will be recognized by GEOS::
|
||||
When using :doc:`raw queries </topics/db/sql>`, you must wrap your geometry
|
||||
fields so that the field value can be recognized by GEOS::
|
||||
|
||||
City.objects.raw('SELECT id, name, asText(point) from myapp_city')
|
||||
from django.db import connection
|
||||
# or if you're querying a non-default database:
|
||||
from django.db import connections
|
||||
connection = connections['your_gis_db_alias']
|
||||
|
||||
This is not absolutely required by PostGIS, but generally you should only
|
||||
use raw queries when you know exactly what you are doing.
|
||||
City.objects.raw('SELECT id, name, %s as point from myapp_city' % (connection.ops.select % 'point'))
|
||||
|
||||
You should only use raw queries when you know exactly what you're doing.
|
||||
|
||||
Lazy Geometries
|
||||
---------------
|
||||
|
|
|
@ -611,6 +611,11 @@ Miscellaneous
|
|||
|
||||
* Support for GEOS 3.3.x is dropped.
|
||||
|
||||
* The way data is selected for ``GeometryField`` is changed to improve
|
||||
performance, and in raw SQL queries, those fields must now be wrapped in
|
||||
``connection.ops.select``. See the :ref:`Raw queries note<gis-raw-sql>` in
|
||||
the GIS tutorial for an example.
|
||||
|
||||
.. _deprecated-features-2.0:
|
||||
|
||||
Features deprecated in 2.0
|
||||
|
|
Loading…
Reference in New Issue