Fix SQLAlchemy backend metadata filtering. meta-filtering
authorchazapis <chazapis@gmail.com>
Fri, 23 Dec 2011 14:06:26 +0000 (16:06 +0200)
committerchazapis <chazapis@gmail.com>
Fri, 23 Dec 2011 14:06:26 +0000 (16:06 +0200)
Refs #1789

pithos/backends/lib/sqlalchemy/node.py

index 39f5edc..1aec4fb 100644 (file)
@@ -844,24 +844,21 @@ class Node(DBWorker):
             included, excluded, opers = parse_filters(filterq)
             if included:
                 subs = select([1])
-                subs = subs.where(a.c.serial == v.c.serial)
+                subs = subs.where(a.c.serial == v.c.serial).correlate(v)
                 subs = subs.where(a.c.domain == domain)
                 subs = subs.where(or_(*[a.c.key.op('=')(x) for x in included]))
-                print '---', str(subs)
                 s = s.where(exists(subs))
             if excluded:
                 subs = select([1])
-                subs = subs.where(a.c.serial == v.c.serial)
+                subs = subs.where(a.c.serial == v.c.serial).correlate(v)
                 subs = subs.where(a.c.domain == domain)
                 subs = subs.where(or_(*[a.c.key.op('=')(x) for x in excluded]))
-                print '---', str(subs)
                 s = s.where(not_(exists(subs)))
             if opers:
                 subs = select([1])
-                subs = subs.where(a.c.serial == v.c.serial)
+                subs = subs.where(a.c.serial == v.c.serial).correlate(v)
                 subs = subs.where(a.c.domain == domain)
-                subs = subs.where(and_(*[a.c.key == k and a.c.value.op(o)(v) for k, o, v in opers]))
-                print '---', str(subs)
+                subs = subs.where(and_(*[and_(a.c.key.op('=')(k), a.c.value.op(o)(v)) for k, o, v in opers]))
                 s = s.where(exists(subs))
         
         s = s.order_by(n.c.path)