Skip to content

Commit

Permalink
Cleanup based on review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akaariai committed Dec 29, 2013
1 parent 1016159 commit 31b8faa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
7 changes: 3 additions & 4 deletions django/contrib/gis/db/models/constants.py
@@ -1,6 +1,6 @@
from django.db.models.sql.constants import QUERY_TERMS

ALL_TERMS = set([
GIS_LOOKUPS = {
'bbcontains', 'bboverlaps', 'contained', 'contains',
'contains_properly', 'coveredby', 'covers', 'crosses', 'disjoint',
'distance_gt', 'distance_gte', 'distance_lt', 'distance_lte',
Expand All @@ -9,8 +9,7 @@
'left', 'right', 'overlaps_left', 'overlaps_right',
'overlaps_above', 'overlaps_below',
'strictly_above', 'strictly_below'
])
GIS_LOOKUPS = ALL_TERMS.copy()
ALL_TERMS.update(QUERY_TERMS)
}
ALL_TERMS = GIS_LOOKUPS | QUERY_TERMS

__all__ = ['ALL_TERMS', 'GIS_LOOKUPS']
18 changes: 11 additions & 7 deletions django/db/backends/utils.py
Expand Up @@ -201,16 +201,20 @@ def format_number(value, max_digits, decimal_places):


def get_implementations(vendor):
try:
implementation = compile_implementations[vendor]
except KeyError:
# TODO: do we need thread safety here? We could easily use an lock...
implementation = {}
compile_implementations[vendor] = implementation
return implementation
return compile_implementations[vendor]


class add_implementation(object):
"""
A decorator to allow customised implementations for query expressions.
For example:
@add_implementation(Exact, 'mysql')
def mysql_exact(node, qn, connection):
# Play with the node here.
return somesql, list_of_params
Now Exact nodes are compiled to SQL using mysql_exact instead of
Exact.as_sql() when using MySQL backend.
"""
def __init__(self, klass, vendor):
self.klass = klass
self.vendor = vendor
Expand Down

0 comments on commit 31b8faa

Please sign in to comment.