Browse Source

Update the quer_filter spliting method to handle superior.nature field notation.

Update the associated tests
Yann Weber 9 years ago
parent
commit
2c37a9bf46
2 changed files with 3 additions and 1 deletions
  1. 1
    1
      leobject/leobject.py
  2. 2
    0
      leobject/test/test_leobject.py

+ 1
- 1
leobject/leobject.py View File

@@ -157,7 +157,7 @@ class _LeObject(object):
157 157
         for operator in cls._query_operators[1:]:
158 158
             op_re_piece += '|(%s)'%operator.replace(' ', '\s')
159 159
         op_re_piece += ')'
160
-        cls._query_re = re.compile('^\s*(?P<field>[a-z_][a-z0-9\-_]*)\s*'+op_re_piece+'\s*(?P<value>[^<>=!].*)\s*$', flags=re.IGNORECASE)
160
+        cls._query_re = re.compile('^\s*(?P<field>(superior\.)?[a-z_][a-z0-9\-_]*)\s*'+op_re_piece+'\s*(?P<value>[^<>=!].*)\s*$', flags=re.IGNORECASE)
161 161
         pass
162 162
 
163 163
 class LeObjectError(Exception):

+ 2
- 0
leobject/test/test_leobject.py View File

@@ -25,6 +25,7 @@ class _LeObjectTestCase(TestCase):
25 25
             "hello \nnot\tin \nfoo":('hello', ' not in ', 'foo'),
26 26
             'hello != bar':('hello', '!=', 'bar'),
27 27
             'hello = "world>= <= != in not in"': ('hello', '=', '"world>= <= != in not in"'),
28
+            'superior.parent = 13': ('superior.parent', '=', '13'),
28 29
         }
29 30
         for query, result in query_results.items():
30 31
             res = _LeObject._split_filter(query)
@@ -42,6 +43,7 @@ class _LeObjectTestCase(TestCase):
42 43
             '=',
43 44
             '42',
44 45
             '"hello" = world',
46
+            'foo.bar = 15',
45 47
         ]
46 48
         for query in invalid_queries:
47 49
             with self.assertRaises(ValueError, msg='But the query was not valid : "%s"'%query):

Loading…
Cancel
Save