db.select(): added [NOT filter]
This commit is contained in:
parent
f45c75988c
commit
2195c2e885
@ -1881,18 +1881,18 @@ class DbWriteBase(DbReadBase):
|
|||||||
filter=None):
|
filter=None):
|
||||||
"""
|
"""
|
||||||
Default implementation of a select for those databases
|
Default implementation of a select for those databases
|
||||||
that don't support SQL. Returns a list of dicts, and total.
|
that don't support SQL. Returns a list of dicts, total,
|
||||||
|
and time.
|
||||||
|
|
||||||
table - Person, Family, etc.
|
table - Person, Family, etc.
|
||||||
fields - used by object.get_field()
|
fields - used by object.get_field()
|
||||||
sort - use sort order (argument to DB.get_X_handles)
|
sort - use sort order (argument to DB.get_X_handles)
|
||||||
start - position to start
|
start - position to start
|
||||||
limit - count to get; -1 for all
|
limit - count to get; -1 for all
|
||||||
filter - (field, SQL string_operator, value)
|
filter - (field, SQL string_operator, value) |
|
||||||
["AND", [filter, filter, ...]]
|
["AND", [filter, filter, ...]] |
|
||||||
["OR", [filter, filter, ...]]
|
["OR", [filter, filter, ...]] |
|
||||||
|
["NOT", filter]
|
||||||
handles all SQL except for NOT expression, eg NOT x = y
|
|
||||||
"""
|
"""
|
||||||
class Result(list):
|
class Result(list):
|
||||||
"""
|
"""
|
||||||
@ -1900,6 +1900,7 @@ class DbWriteBase(DbReadBase):
|
|||||||
and time = time to select.
|
and time = time to select.
|
||||||
"""
|
"""
|
||||||
total = 0
|
total = 0
|
||||||
|
time = 0.0
|
||||||
def hash_name(table, name):
|
def hash_name(table, name):
|
||||||
"""
|
"""
|
||||||
Used in filter to eval expressions involving selected
|
Used in filter to eval expressions involving selected
|
||||||
@ -1954,7 +1955,7 @@ class DbWriteBase(DbReadBase):
|
|||||||
"""
|
"""
|
||||||
Evaluates the names in all conditions.
|
Evaluates the names in all conditions.
|
||||||
"""
|
"""
|
||||||
if len(condition) == 2: # ["AND"|"OR" [...]]
|
if len(condition) == 2: # ["AND" [...]] | ["OR" [...]] | ["NOT" expr]
|
||||||
connector, exprs = condition
|
connector, exprs = condition
|
||||||
for expr in exprs:
|
for expr in exprs:
|
||||||
evaluate_values(expr, item, db, table, env)
|
evaluate_values(expr, item, db, table, env)
|
||||||
@ -1979,6 +1980,8 @@ class DbWriteBase(DbReadBase):
|
|||||||
if evaluate_truth(expr, item, db, table, env):
|
if evaluate_truth(expr, item, db, table, env):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
elif connector == "NOT": # return not of single value
|
||||||
|
return not evaluate_truth(exprs, item, db, table, env)
|
||||||
else:
|
else:
|
||||||
raise Exception("No such connector: '%s'" % connector)
|
raise Exception("No such connector: '%s'" % connector)
|
||||||
elif len(condition) == 3: # (name, op, value)
|
elif len(condition) == 3: # (name, op, value)
|
||||||
|
Loading…
Reference in New Issue
Block a user