Skip to content

Commit

Permalink
Refs #11109 -- Touched some whitespace so Trac will display some file…
Browse files Browse the repository at this point in the history
…s correctly.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11785 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Dec 2, 2009
1 parent 9722091 commit ce7c61d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
6 changes: 3 additions & 3 deletions django/contrib/gis/db/backend/mysql/query.py
Expand Up @@ -4,7 +4,7 @@
Please note that MySQL only supports bounding box queries, also Please note that MySQL only supports bounding box queries, also
known as MBRs (Minimum Bounding Rectangles). Moreover, spatial known as MBRs (Minimum Bounding Rectangles). Moreover, spatial
indices may only be used on MyISAM tables -- if you need indices may only be used on MyISAM tables -- if you need
transactions, take a look at PostGIS. transactions, take a look at PostGIS.
""" """
from django.db import connection from django.db import connection
Expand Down Expand Up @@ -38,7 +38,7 @@
# Assacceptable lookup types for Oracle spatial. # Assacceptable lookup types for Oracle spatial.
MYSQL_GIS_TERMS = MYSQL_GIS_FUNCTIONS.keys() MYSQL_GIS_TERMS = MYSQL_GIS_FUNCTIONS.keys()
MYSQL_GIS_TERMS += MISC_TERMS MYSQL_GIS_TERMS += MISC_TERMS
MYSQL_GIS_TERMS = dict((term, None) for term in MYSQL_GIS_TERMS) # Making dictionary MYSQL_GIS_TERMS = dict((term, None) for term in MYSQL_GIS_TERMS) # Making dictionary


def get_geo_where_clause(table_alias, name, lookup_type, geo_annot): def get_geo_where_clause(table_alias, name, lookup_type, geo_annot):
"Returns the SQL WHERE clause for use in MySQL spatial SQL construction." "Returns the SQL WHERE clause for use in MySQL spatial SQL construction."
Expand All @@ -49,7 +49,7 @@ def get_geo_where_clause(table_alias, name, lookup_type, geo_annot):
lookup_info = MYSQL_GIS_FUNCTIONS.get(lookup_type, False) lookup_info = MYSQL_GIS_FUNCTIONS.get(lookup_type, False)
if lookup_info: if lookup_info:
return "%s(%s, %%s)" % (lookup_info, geo_col) return "%s(%s, %%s)" % (lookup_info, geo_col)

# Handling 'isnull' lookup type # Handling 'isnull' lookup type
# TODO: Is this needed because MySQL cannot handle NULL # TODO: Is this needed because MySQL cannot handle NULL
# geometries in its spatial indices. # geometries in its spatial indices.
Expand Down
28 changes: 14 additions & 14 deletions django/contrib/gis/db/backend/oracle/query.py
Expand Up @@ -3,8 +3,8 @@
routine for Oracle Spatial. routine for Oracle Spatial.
Please note that WKT support is broken on the XE version, and thus Please note that WKT support is broken on the XE version, and thus
this backend will not work on such platforms. Specifically, XE lacks this backend will not work on such platforms. Specifically, XE lacks
support for an internal JVM, and Java libraries are required to use support for an internal JVM, and Java libraries are required to use
the WKT constructors. the WKT constructors.
""" """
import re import re
Expand All @@ -31,10 +31,10 @@
UNION = 'SDO_GEOM.SDO_UNION' UNION = 'SDO_GEOM.SDO_UNION'
UNIONAGG = 'SDO_AGGR_UNION' UNIONAGG = 'SDO_AGGR_UNION'


# We want to get SDO Geometries as WKT because it is much easier to # We want to get SDO Geometries as WKT because it is much easier to
# instantiate GEOS proxies from WKT than SDO_GEOMETRY(...) strings. # instantiate GEOS proxies from WKT than SDO_GEOMETRY(...) strings.
# However, this adversely affects performance (i.e., Java is called # However, this adversely affects performance (i.e., Java is called
# to convert to WKT on every query). If someone wishes to write a # to convert to WKT on every query). If someone wishes to write a
# SDO_GEOMETRY(...) parser in Python, let me know =) # SDO_GEOMETRY(...) parser in Python, let me know =)
GEOM_SELECT = 'SDO_UTIL.TO_WKTGEOMETRY(%s)' GEOM_SELECT = 'SDO_UTIL.TO_WKTGEOMETRY(%s)'


Expand All @@ -50,7 +50,7 @@ def __init__(self, func, **kwargs):
class SDODistance(SpatialFunction): class SDODistance(SpatialFunction):
"Class for Distance queries." "Class for Distance queries."
def __init__(self, op, tolerance=0.05): def __init__(self, op, tolerance=0.05):
super(SDODistance, self).__init__(DISTANCE, end_subst=', %s) %%s %%s' % tolerance, super(SDODistance, self).__init__(DISTANCE, end_subst=', %s) %%s %%s' % tolerance,
operator=op, result='%%s') operator=op, result='%%s')


class SDOGeomRelate(SpatialFunction): class SDOGeomRelate(SpatialFunction):
Expand All @@ -59,7 +59,7 @@ def __init__(self, mask, tolerance=0.05):
# SDO_GEOM.RELATE(...) has a peculiar argument order: column, mask, geom, tolerance. # SDO_GEOM.RELATE(...) has a peculiar argument order: column, mask, geom, tolerance.
# Moreover, the runction result is the mask (e.g., 'DISJOINT' instead of 'TRUE'). # Moreover, the runction result is the mask (e.g., 'DISJOINT' instead of 'TRUE').
end_subst = "%s%s) %s '%s'" % (', %%s, ', tolerance, '=', mask) end_subst = "%s%s) %s '%s'" % (', %%s, ', tolerance, '=', mask)
beg_subst = "%%s(%%s, '%s'" % mask beg_subst = "%%s(%%s, '%s'" % mask
super(SDOGeomRelate, self).__init__('SDO_GEOM.RELATE', beg_subst=beg_subst, end_subst=end_subst) super(SDOGeomRelate, self).__init__('SDO_GEOM.RELATE', beg_subst=beg_subst, end_subst=end_subst)


class SDORelate(SpatialFunction): class SDORelate(SpatialFunction):
Expand All @@ -81,7 +81,7 @@ def __init__(self, mask):
'distance_gte' : (SDODistance('>='), dtypes), 'distance_gte' : (SDODistance('>='), dtypes),
'distance_lt' : (SDODistance('<'), dtypes), 'distance_lt' : (SDODistance('<'), dtypes),
'distance_lte' : (SDODistance('<='), dtypes), 'distance_lte' : (SDODistance('<='), dtypes),
'dwithin' : (SDOOperation('SDO_WITHIN_DISTANCE', 'dwithin' : (SDOOperation('SDO_WITHIN_DISTANCE',
beg_subst="%s(%s, %%s, 'distance=%%s'"), dtypes), beg_subst="%s(%s, %%s, 'distance=%%s'"), dtypes),
} }


Expand Down Expand Up @@ -118,7 +118,7 @@ def get_geo_where_clause(table_alias, name, lookup_type, geo_annot):
# See if a Oracle Geometry function matches the lookup type next # See if a Oracle Geometry function matches the lookup type next
lookup_info = ORACLE_GEOMETRY_FUNCTIONS.get(lookup_type, False) lookup_info = ORACLE_GEOMETRY_FUNCTIONS.get(lookup_type, False)
if lookup_info: if lookup_info:
# Lookup types that are tuples take tuple arguments, e.g., 'relate' and # Lookup types that are tuples take tuple arguments, e.g., 'relate' and
# 'dwithin' lookup types. # 'dwithin' lookup types.
if isinstance(lookup_info, tuple): if isinstance(lookup_info, tuple):
# First element of tuple is lookup type, second element is the type # First element of tuple is lookup type, second element is the type
Expand All @@ -128,23 +128,23 @@ def get_geo_where_clause(table_alias, name, lookup_type, geo_annot):
# Ensuring that a tuple _value_ was passed in from the user # Ensuring that a tuple _value_ was passed in from the user
if not isinstance(geo_annot.value, tuple): if not isinstance(geo_annot.value, tuple):
raise TypeError('Tuple required for `%s` lookup type.' % lookup_type) raise TypeError('Tuple required for `%s` lookup type.' % lookup_type)
if len(geo_annot.value) != 2: if len(geo_annot.value) != 2:
raise ValueError('2-element tuple required for %s lookup type.' % lookup_type) raise ValueError('2-element tuple required for %s lookup type.' % lookup_type)

# Ensuring the argument type matches what we expect. # Ensuring the argument type matches what we expect.
if not isinstance(geo_annot.value[1], arg_type): if not isinstance(geo_annot.value[1], arg_type):
raise TypeError('Argument type should be %s, got %s instead.' % (arg_type, type(geo_annot.value[1]))) raise TypeError('Argument type should be %s, got %s instead.' % (arg_type, type(geo_annot.value[1])))


if lookup_type == 'relate': if lookup_type == 'relate':
# The SDORelate class handles construction for these queries, # The SDORelate class handles construction for these queries,
# and verifies the mask argument. # and verifies the mask argument.
return sdo_op(geo_annot.value[1]).as_sql(geo_col) return sdo_op(geo_annot.value[1]).as_sql(geo_col)
else: else:
# Otherwise, just call the `as_sql` method on the SDOOperation instance. # Otherwise, just call the `as_sql` method on the SDOOperation instance.
return sdo_op.as_sql(geo_col) return sdo_op.as_sql(geo_col)
else: else:
# Lookup info is a SDOOperation instance, whose `as_sql` method returns # Lookup info is a SDOOperation instance, whose `as_sql` method returns
# the SQL necessary for the geometry function call. For example: # the SQL necessary for the geometry function call. For example:
# SDO_CONTAINS("geoapp_country"."poly", SDO_GEOMTRY('POINT(5 23)', 4326)) = 'TRUE' # SDO_CONTAINS("geoapp_country"."poly", SDO_GEOMTRY('POINT(5 23)', 4326)) = 'TRUE'
return lookup_info.as_sql(geo_col) return lookup_info.as_sql(geo_col)
elif lookup_type == 'isnull': elif lookup_type == 'isnull':
Expand Down
1 change: 1 addition & 0 deletions tests/regressiontests/bash_completion/__init__.py
@@ -0,0 +1 @@

@@ -0,0 +1 @@

@@ -0,0 +1 @@

Expand Up @@ -3,6 +3,7 @@


from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand



class Command(BaseCommand): class Command(BaseCommand):
option_list = BaseCommand.option_list + ( option_list = BaseCommand.option_list + (
make_option("--list", action="store_true", dest="list", make_option("--list", action="store_true", dest="list",
Expand Down
1 change: 1 addition & 0 deletions tests/regressiontests/bash_completion/models.py
@@ -0,0 +1 @@

0 comments on commit ce7c61d

Please sign in to comment.