Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup based on review comments

  • Loading branch information...
commit 31b8faa62714b4b6b6057a9f5cc106c4dd73caab 1 parent 1016159
Anssi Kääriäinen akaariai authored
7 django/contrib/gis/db/models/constants.py
View
@@ -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',
@@ -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 django/db/backends/utils.py
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.