Skip to content

Commit 2cda89d

Browse files
author
hugo
committed
FIX: hdfstore queries of the form where=[('date', '>=', datetime(2013,1,1)), ('date', '<=', datetime(2014,1,1))] were broken
- modified Expr.parse_back_compat to check for tuples, in w, and unpack into w, op, value - modified Expr.__init__ to modify the where list/tuple with the parsed result
1 parent 173c686 commit 2cda89d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

pandas/computation/pytables.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@ def __init__(self, where, op=None, value=None, queryables=None,
488488
self.filter = None
489489
self.terms = None
490490
self._visitor = None
491-
492491
# capture the environement if needed
493492
lcls = dict()
494493
if isinstance(where, Expr):
@@ -497,13 +496,12 @@ def __init__(self, where, op=None, value=None, queryables=None,
497496
where = where.expr
498497

499498
elif isinstance(where, (list, tuple)):
500-
501-
for w in where:
499+
for idx, w in enumerate(where):
502500
if isinstance(w, Expr):
503501
lcls.update(w.env.locals)
504502
else:
505503
w = self.parse_back_compat(w)
506-
504+
where[idx] = w
507505
where = ' & ' .join(["(%s)" % w for w in where])
508506

509507
self.expr = where
@@ -528,7 +526,16 @@ def parse_back_compat(self, w, op=None, value=None):
528526
warnings.warn("passing a dict to Expr is deprecated, "
529527
"pass the where as a single string",
530528
DeprecationWarning)
531-
529+
if isinstance(w, tuple):
530+
if len(w) == 2:
531+
w, value = w
532+
op = '=='
533+
elif len(w) == 3:
534+
w, op, value = w
535+
warnings.warn("passing a tuple into Expr is deprecated, "
536+
"pass the where as a single string",
537+
DeprecationWarning)
538+
532539
if op is not None:
533540
if not isinstance(w, string_types):
534541
raise TypeError(

0 commit comments

Comments
 (0)