Browse Source

Implementation of the prepare method for LeDeleteQuery with the check of the validity of the query filters operators

Roland Haroutiounian 9 years ago
parent
commit
c342a85995
1 changed files with 11 additions and 2 deletions
  1. 11
    2
      lodel/leapi/query.py

+ 11
- 2
lodel/leapi/query.py View File

@@ -20,6 +20,13 @@ class LeQuery(object):
20 20
             raise TypeError("target class has to be a child class of LeObject")
21 21
         self._target_class = target_class
22 22
 
23
+    @classmethod
24
+    def validate_query_filters(cls, query_filters):
25
+        for query_filter in query_filters:
26
+            if query_filter[1] not in cls._query_operators:
27
+                raise LeQueryError("The operator %s is not valid." % query_filter[1])
28
+        return True
29
+
23 30
 
24 31
 class LeInsertQuery(LeQuery):
25 32
     action = 'insert'
@@ -145,5 +152,7 @@ class LeDeleteQuery(LeFilteredQuery):
145 152
         return ret
146 153
 
147 154
     def __prepare(self):
148
-        # TODO add the checks on the query_filters if needed
149
-        pass
155
+        datas = dict()
156
+        if LeQuery.validate_query_filters(self.query_filters):
157
+            datas['query_filters'] = self.query_filters
158
+        return datas

Loading…
Cancel
Save