﻿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
17448	Error reading PointField in objects.raw(sql) query	oluckyman	David Eklund	"There is a model:
{{{#!python
class Place(models.Model):
    ...
    location = models.PointField(srid=4326)
    objects = models.GeoManager()
    ...
}}}
Expecting result of {{{Place.objects.raw('select * from places_place')[0].location}}} is the same as {{{Place.objects.all()[0].location}}}

Test it in the shell:
{{{#!python
In [1]: Place.objects.all()[0].location
Out[1]: <Point object at 0x1042e9400>

In [2]: Place.objects.raw('select * from places_place')[0].location
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (140, 0))

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/local/lib/python2.7/site-packages/django_extensions/management/commands/shell_plus.pyc in <module>()
----> 1 Place.objects.raw(u'select * from places_place')[0].location

/usr/local/lib/python2.7/site-packages/django/contrib/gis/db/models/proxy.pyc in __get__(self, obj, type)
     36             # Otherwise, a Geometry object is built using the field's contents,

     37             # and the model's corresponding attribute is set.

---> 38             geom = self._klass(geom_value)
     39             setattr(obj, self._field.attname, geom)
     40         return geom

/usr/local/lib/python2.7/site-packages/django/contrib/gis/geos/geometry.pyc in __init__(self, geo_input, srid)
     72                 g = wkb_r().read(gdal.OGRGeometry(geo_input).wkb)
     73             else:
---> 74                 raise ValueError('String or unicode input unrecognized as WKT EWKT, and HEXEWKB.')
     75         elif isinstance(geo_input, GEOM_PTR):
     76             # When the input is a pointer to a geomtry (GEOM_PTR).


ValueError: String or unicode input unrecognized as WKT EWKT, and HEXEWKB.
}}}"	Bug	closed	GIS	1.3	Normal	fixed	raw sql gis	daek@…	Accepted	0	0	0	0	0	0
