Skip to content

Commit

Permalink
Merge 20f17aa into c3553af
Browse files Browse the repository at this point in the history
  • Loading branch information
vstoykov committed Nov 6, 2018
2 parents c3553af + 20f17aa commit d862c5c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions tinydb/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ class Query(QueryImpl):
"""

def __init__(self):
self._path = []
self._path = ()
super(Query, self).__init__(
self._prepare_test(lambda _: True),
('path', tuple(self._path))
('path', self._path)
)

def __repr__(self):
Expand All @@ -119,8 +119,8 @@ def __hash__(self):

def __getattr__(self, item):
query = Query()
query._path = self._path + [item]
query.hashval = ('path', tuple(query._path))
query._path = self._path + (item, )
query.hashval = ('path', query._path)

return query

Expand Down Expand Up @@ -180,7 +180,7 @@ def test(value):

return self._generate_test(
lambda value: test(value),
('==', tuple(self._path), freeze(rhs))
('==', self._path, freeze(rhs))
)

def __ne__(self, rhs):
Expand All @@ -193,7 +193,7 @@ def __ne__(self, rhs):
"""
return self._generate_test(
lambda value: value != rhs,
('!=', tuple(self._path), freeze(rhs))
('!=', self._path, freeze(rhs))
)

def __lt__(self, rhs):
Expand All @@ -206,7 +206,7 @@ def __lt__(self, rhs):
"""
return self._generate_test(
lambda value: value < rhs,
('<', tuple(self._path), rhs)
('<', self._path, rhs)
)

def __le__(self, rhs):
Expand All @@ -219,7 +219,7 @@ def __le__(self, rhs):
"""
return self._generate_test(
lambda value: value <= rhs,
('<=', tuple(self._path), rhs)
('<=', self._path, rhs)
)

def __gt__(self, rhs):
Expand All @@ -232,7 +232,7 @@ def __gt__(self, rhs):
"""
return self._generate_test(
lambda value: value > rhs,
('>', tuple(self._path), rhs)
('>', self._path, rhs)
)

def __ge__(self, rhs):
Expand All @@ -245,7 +245,7 @@ def __ge__(self, rhs):
"""
return self._generate_test(
lambda value: value >= rhs,
('>=', tuple(self._path), rhs)
('>=', self._path, rhs)
)

def exists(self):
Expand All @@ -256,7 +256,7 @@ def exists(self):
"""
return self._generate_test(
lambda _: True,
('exists', tuple(self._path))
('exists', self._path)
)

def matches(self, regex, flags=0):
Expand All @@ -269,7 +269,7 @@ def matches(self, regex, flags=0):
"""
return self._generate_test(
lambda value: re.match(regex, value, flags),
('matches', tuple(self._path), regex)
('matches', self._path, regex)
)

def search(self, regex, flags=0):
Expand All @@ -283,7 +283,7 @@ def search(self, regex, flags=0):
"""
return self._generate_test(
lambda value: re.search(regex, value, flags),
('search', tuple(self._path), regex)
('search', self._path, regex)
)

def test(self, func, *args):
Expand All @@ -301,7 +301,7 @@ def test(self, func, *args):
"""
return self._generate_test(
lambda value: func(value, *args),
('test', tuple(self._path), func, args)
('test', self._path, func, args)
)

def any(self, cond):
Expand Down Expand Up @@ -336,7 +336,7 @@ def _cmp(value):

return self._generate_test(
lambda value: _cmp(value),
('any', tuple(self._path), freeze(cond))
('any', self._path, freeze(cond))
)

def all(self, cond):
Expand Down Expand Up @@ -369,7 +369,7 @@ def _cmp(value):

return self._generate_test(
lambda value: _cmp(value),
('all', tuple(self._path), freeze(cond))
('all', self._path, freeze(cond))
)

def one_of(self, items):
Expand All @@ -382,7 +382,7 @@ def one_of(self, items):
"""
return self._generate_test(
lambda value: value in items,
('one_of', tuple(self._path), freeze(items))
('one_of', self._path, freeze(items))
)


Expand Down

0 comments on commit d862c5c

Please sign in to comment.