Beispiel #1
0
def monkey_patch_where_node():

    global monkey_patched
    if monkey_patched is True:
        return
    monkey_patched = True

    if django.VERSION >= (1,5):
        from django.db.models.sql.constants import QUERY_TERMS
        QUERY_TERMS.update(UnaccentOperation.operators.keys() + UnaccentOperation.smart_operators)

    # Update the operators accepted by a query when adding filters by adding those of unaccent
    # This way, it passes the test at db/models/sql/query.py:1021 which otherwise will override our custom lookup_types
    Query.query_terms.update(izip(UnaccentOperation.operators.keys() + UnaccentOperation.smart_operators, repeat(None)))
    WhereNode.add = patched_wherenode_add
Beispiel #2
0
    'strictly_above',
    'notextend_above',
    'notextend_below',
    'is_below',
    'is_above',
    'intersects',
    'is_horizontal',
    'is_perpendicular',
    'is_parallel',
    'contained_in_or_on',
    'same_as',
    'contains',
    'center',
)

GEOMETRIC_LOOKUPS = dict((x, None) for x in geometric_lookups)
FTS_LOCKUPS = {'query': None, 'query_raw':None}
VARCHAR_LOOKUPS = dict((x, None) for x in ('unaccent', 'iunaccent'))
INTERVAL_LOOKUPS = dict((x, None) for x in  ('distinct', 'exact', 'gt','lt','gte', 'lte'))
ARRAY_LOOKUPS = dict((x, None) for x in ('indexexact', 'distinct', 'slice', 'contains', 
                                'containedby', 'overlap', 'exact', 'gt','lt','gte', 'lte'))

QUERY_TERMS.update(GEOMETRIC_LOOKUPS)
QUERY_TERMS.update(FTS_LOCKUPS)
QUERY_TERMS.update(VARCHAR_LOOKUPS)
QUERY_TERMS.update(INTERVAL_LOOKUPS)
QUERY_TERMS.update(ARRAY_LOOKUPS)

GEOMETRIC_TYPES = dict((x, None) for x in \
    ('box', 'point', 'line', 'lseg', 'path', 'polygon', 'circle'))
Beispiel #3
0
    'center',               # center(object)
    'area',                 # area(object)
    'area_gt',
    'area_lt',
    'area_gte',
    'area_lte',
    'overlap',
    'strictly_left_of',
    'strictly_right_of',
    'notextendto_right_of',
    'notextendto_left_of',
    'strictly_below',
    'strictly_above',
    'notextend_above',
    'notextend_below',
    'is_below',
    'is_above',
    'intersects',
    'is_horizontal',
    'is_perpendicular',
    'is_parallel',
    'contained_in_or_on',
    'contains',
    'same_as',
)

QUERY_TERMS.update(dict([(x, None) for x in \
    ('indexexact', 'distinct', 'slice', 'containedby', 'unaccent', 'iunaccent', 'query')]))

QUERY_TERMS.update(dict([(x, None) for x in geometric_lookups]))
Beispiel #4
0
# -*- coding: utf-8 -*-

from django.db.models.sql.constants import QUERY_TERMS

QUERY_TERMS.update(dict([(x, None) for x in ['unaccent', 'iunaccent']]))