Add a " LIMIT " keyword in conditions
This commit is contained in:
parent
e877f8faa6
commit
d73c6b2245
3 changed files with 23 additions and 3 deletions
|
|
@ -278,8 +278,13 @@ class Application(object):
|
|||
|
||||
def _do_complete_iter(self, backend, count, fields, res):
|
||||
modif = 0
|
||||
|
||||
for i, sub in enumerate(res):
|
||||
sub = self._do_complete_obj(backend, fields, sub)
|
||||
if self.condition and self.condition.limit and \
|
||||
self.condition.limit == i:
|
||||
return
|
||||
|
||||
if self.condition and not self.condition.is_valid(sub):
|
||||
modif += 1
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -69,7 +69,15 @@ class ResultsCondition(IResultsCondition):
|
|||
# =, != for strings
|
||||
# We build a list of list. Return true if each conditions of one list is TRUE
|
||||
def __init__(self, condition_str):
|
||||
self.limit = None
|
||||
or_list = []
|
||||
_condition_str = condition_str.split(' LIMIT ')
|
||||
if len(_condition_str) == 2:
|
||||
try:
|
||||
self.limit = int(_condition_str[1])
|
||||
except ValueError:
|
||||
raise ResultsConditionError(u'Syntax error in the condition expression, please check documentation')
|
||||
condition_str= _condition_str[0]
|
||||
for _or in condition_str.split(' OR '):
|
||||
and_list = []
|
||||
for _and in _or.split(' AND '):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue