#28632: Models having gis fields cannot be used with Manager.raw()
--------------------------+--------------------------------------
Reporter: gcbirzan | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------+--------------------------------------
Description changed by gcbirzan:
Old description:
> This bug was introduced in
> [https://github.com/django/django/commit/1a85b07bddbf43da00311bdbb3ef5519a3165dc6
> 1a85b07bddbf43da00311bdbb3ef5519a3165dc6] (I found it with git bisect).
> Trying to do this results in:
>
> {{{
> ======================================================================
> ERROR: test_17_raw_query
> (gis_tests.relatedapp.test_new.RelatedGeoModelTest)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File
> "/home/gcbirzan/PycharmProjects/django/tests/gis_tests/relatedapp/test_new.py",
> line 10, in test_17_raw_query
> list(raw)
> File "/home/gcbirzan/PycharmProjects/django/django/db/models/query.py",
> line 1234, in __iter__
> for values in query:
> File
> "/home/gcbirzan/PycharmProjects/django/django/db/models/sql/compiler.py",
> line 949, in apply_converters
> value = converter(value, expression, connection)
> File
> "/home/gcbirzan/PycharmProjects/django/django/contrib/gis/db/backends/postgis/operations.py",
> line 395, in <lambda>
> return lambda value, expression, connection: None if value is None
> else GEOSGeometry(read(value))
> File
> "/home/gcbirzan/PycharmProjects/django/django/contrib/gis/geos/prototypes/io.py",
> line 153, in read
> return wkb_reader_read_hex(self.ptr, wkb, len(wkb))
> File
> "/home/gcbirzan/PycharmProjects/django/django/contrib/gis/geos/libgeos.py",
> line 164, in __call__
> return self.func(*args, **kwargs)
> File
> "/home/gcbirzan/PycharmProjects/django/django/contrib/gis/geos/prototypes/threadsafe.py",
> line 55, in __call__
> return self.cfunc(self.thread_context.handle.ptr, *args)
> ctypes.ArgumentError: argument 3: <class 'TypeError'>: wrong type
>
> ----------------------------------------------------------------------
> }}}
>
> This is on python 3.6.3rc1 with libgdal 2.2.1+dfsg-2+b2 (debian sid).
>
> the test I'm using is:
>
> {{{
> from django.test import TestCase
> from .models import Location
>
> class RelatedGeoModelTest(TestCase):
> fixtures = ['initial']
>
> def test_17_raw_query(self):
> raw = Location.objects.raw("SELECT * FROM
> {}".format(Location._meta.db_table))
> list(raw)
>
> }}}
New description:
This bug was introduced in
[https://github.com/django/django/commit/1a85b07bddbf43da00311bdbb3ef5519a3165dc6
1a85b07bddbf43da00311bdbb3ef5519a3165dc6] (I found it with git bisect).
Trying to do this results in:
{{{
======================================================================
ERROR: test_17_raw_query
(gis_tests.relatedapp.test_new.RelatedGeoModelTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/gcbirzan/PycharmProjects/django/tests/gis_tests/relatedapp/test_new.py",
line 10, in test_17_raw_query
list(raw)
File "/home/gcbirzan/PycharmProjects/django/django/db/models/query.py",
line 1234, in __iter__
for values in query:
File
"/home/gcbirzan/PycharmProjects/django/django/db/models/sql/compiler.py",
line 949, in apply_converters
value = converter(value, expression, connection)
File
"/home/gcbirzan/PycharmProjects/django/django/contrib/gis/db/backends/postgis/operations.py",
line 395, in <lambda>
return lambda value, expression, connection: None if value is None
else GEOSGeometry(read(value))
File
"/home/gcbirzan/PycharmProjects/django/django/contrib/gis/geos/prototypes/io.py",
line 153, in read
return wkb_reader_read_hex(self.ptr, wkb, len(wkb))
File
"/home/gcbirzan/PycharmProjects/django/django/contrib/gis/geos/libgeos.py",
line 164, in __call__
return self.func(*args, **kwargs)
File
"/home/gcbirzan/PycharmProjects/django/django/contrib/gis/geos/prototypes/threadsafe.py",
line 55, in __call__
return self.cfunc(self.thread_context.handle.ptr, *args)
ctypes.ArgumentError: argument 3: <class 'TypeError'>: wrong type
----------------------------------------------------------------------
}}}
the test I'm using is:
{{{
from django.test import TestCase
from .models import Location
class RelatedGeoModelTest(TestCase):
fixtures = ['initial']
def test_17_raw_query(self):
raw = Location.objects.raw("SELECT * FROM
{}".format(Location._meta.db_table))
list(raw)
}}}
This is on python 3.6.3rc1 with libgdal 2.2.1+dfsg-2+b2 (debian sid).
--
--
Ticket URL: <https://code.djangoproject.com/ticket/28632#comment:1>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.aa9632f334a2343ca0e3190ede47917b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.