Re: [Django] #9364: Spatial queries don't work on inherited geometry fields

2008-11-05 Thread Django
#9364: Spatial queries don't work on inherited geometry fields
-+--
  Reporter:  jbronn  | Owner:  jbronn 
Status:  closed  | Milestone:  post-1.0   
 Component:  GIS |   Version:  1.0
Resolution:  fixed   |  Keywords:  gis inheritance
 Stage:  Unreviewed  | Has_patch:  0  
Needs_docs:  0   |   Needs_tests:  1  
Needs_better_patch:  0   |  
-+--
Changes (by jbronn):

  * status:  assigned => closed
  * resolution:  => fixed

Comment:

 (In [9336]) Fixed #9364 -- now uses the appropriate database table for
 inherited GeometryFields; now uses the SpatialBackend booleans in tests.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9364: Spatial queries don't work on inherited geometry fields

2008-11-04 Thread Django
#9364: Spatial queries don't work on inherited geometry fields
-+--
  Reporter:  jbronn  | Owner:  jbronn 
Status:  assigned| Milestone:  post-1.0   
 Component:  GIS |   Version:  1.0
Resolution:  |  Keywords:  gis inheritance
 Stage:  Unreviewed  | Has_patch:  0  
Needs_docs:  0   |   Needs_tests:  1  
Needs_better_patch:  0   |  
-+--
Changes (by jbronn):

  * status:  new => assigned
  * needs_tests:  0 => 1

Comment:

 I want tests before I'll commit this -- but this appears to solve the
 problem by using the correct database table name for the inherited
 geometry field.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9364: Spatial queries don't work on inherited geometry fields

2008-10-14 Thread Django
#9364: Spatial queries don't work on inherited geometry fields
-+--
  Reporter:  jbronn  | Owner:  jbronn 
Status:  new | Milestone:  post-1.0   
 Component:  GIS |   Version:  1.0
Resolution:  |  Keywords:  gis inheritance
 Stage:  Unreviewed  | Has_patch:  0  
Needs_docs:  0   |   Needs_tests:  0  
Needs_better_patch:  0   |  
-+--
Changes (by jbronn):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Old description:

> In the following models `TexasCity` inherits from `City`:
>
> {{{
> from django.contrib.gis.db import models
>
> class City(models.Model):
> name = models.CharField(max_length=30)
> point = models.PointField()
> objects = models.GeoManager()
>
> def __unicode__(self): return self.name
>
> class TexasCity(City):
> tx_county = models.CharField(max_length=30)
>
> def __unicode__(self):
> return '%s (%s County)' % (self.name, self.tx_county)
> }}}
>
> When performing the following query:
> {{{
> In [4]: qs = TexasCity.objects.filter(point__distance_lte=(pnt, D(mi=5)))
> }}}
>
> This error is raised:
> {{{
> FieldErrorTraceback (most recent call
> last)
>
> /Users/jbronn/geodjango/ in ()
>
> /Users/jbronn/hg/django/gis/django/db/models/manager.pyc in filter(self,
> *args, **kwargs)
> 100
> 101 def filter(self, *args, **kwargs):
> --> 102 return self.get_query_set().filter(*args, **kwargs)
> 103
> 104 def complex_filter(self, *args, **kwargs):
>
> /Users/jbronn/hg/django/gis/django/db/models/query.pyc in filter(self,
> *args, **kwargs)
> 487 set.
> 488 """
> --> 489 return self._filter_or_exclude(False, *args, **kwargs)
> 490
> 491 def exclude(self, *args, **kwargs):
>
> /Users/jbronn/hg/django/gis/django/db/models/query.pyc in
> _filter_or_exclude(self, negate, *args, **kwargs)
> 505 clone.query.add_q(~Q(*args, **kwargs))
> 506 else:
> --> 507 clone.query.add_q(Q(*args, **kwargs))
> 508 return clone
> 509
>
> /Users/jbronn/hg/django/gis/django/db/models/sql/query.pyc in add_q(self,
> q_object, used_aliases)
>1246 else:
>1247 self.add_filter(child, connector,
> q_object.negated,
> -> 1248 can_reuse=used_aliases)
>1249 if connector == OR:
>1250 # Aliases that were newly added or not used
> at all need to
>
> /Users/jbronn/hg/django/gis/django/db/models/sql/query.pyc in
> add_filter(self, filter_expr, connector, negate, trim, can_reuse,
> process_extras)
>1121 field, target, opts, join_list, last, extra_filters =
> self.setup_joins(
>1122 parts, opts, alias, True, allow_many,
> can_reuse=can_reuse,
> -> 1123 negate=negate, process_extras=process_extras)
>1124 except MultiJoin, e:
>1125 self.split_exclude(filter_expr,
> LOOKUP_SEP.join(parts[:e.level]),
>
> /Users/jbronn/hg/django/gis/django/db/models/sql/query.pyc in
> setup_joins(self, names, opts, alias, dupe_multis, allow_many,
> allow_explicit_fk, can_reuse, negate, process_extras)
>1449
>1450 if pos != len(names) - 1:
> -> 1451 raise FieldError("Join on field %r not permitted." %
> name)
>1452
>1453 return field, target, opts, joins, last, extra_filters
>
> FieldError: Join on field 'point' not permitted.
> }}}

New description:

 In the following models `TexasCity` inherits from `City`:

 {{{
 from django.contrib.gis.db import models

 class City(models.Model):
 name = models.CharField(max_length=30)
 point = models.PointField()
 objects = models.GeoManager()

 def __unicode__(self): return self.name

 class TexasCity(City):
 tx_county = models.CharField(max_length=30)
 objects = models.GeoManager() # Why does this need to be explicit?

 def __unicode__(self):
 return '%s (%s County)' % (self.name, self.tx_county)
 }}}

 When performing the following query:
 {{{
 In [4]: qs = TexasCity.objects.distance(pnt)
 }}}

 This SQL is generated, which is incorrect (there is no "point" column on
 the `TexasCity` model):
 {{{
 In [23]: qs.query.as_sql()
 Out[23]:
 (u'SELECT (ST_distance_sphere("tz_texascity"."point",%s)) AS "distance",
 "tz_city"."id", "tz_city"."name", "tz_city"."point",
 "tz_texascity"."city_ptr_id", "tz_texascity"."tx_county" FROM
 "tz_texascity" INNER JOIN "tz_city" ON ("tz_texascity"."city_ptr_id" =
 "tz_city"."id")',
  (,))
 }}}

-- 
Ticket URL: 
Django