Revision c7c0790f pithos/backends/lib/sqlite/node.py
b/pithos/backends/lib/sqlite/node.py | ||
---|---|---|
606 | 606 |
args = [] |
607 | 607 |
|
608 | 608 |
if included: |
609 |
subq = "a.key in (" |
|
610 |
subq += ','.join(('?' for x in included)) + ")" |
|
609 |
subq = "exists (select 1 from attributes where serial = v.serial and domain = ? and " |
|
610 |
subq += "(" + ' or '.join(('key = ?' for x in included)) + ")" |
|
611 |
subq += ")" |
|
612 |
args += [domain] |
|
611 | 613 |
args += included |
612 | 614 |
append(subq) |
613 | 615 |
|
614 | 616 |
if excluded: |
615 |
subq = "a.key not in (" |
|
616 |
subq += ','.join(('?' for x in excluded)) + ")" |
|
617 |
subq = "not exists (select 1 from attributes where serial = v.serial and domain = ? and " |
|
618 |
subq += "(" + ' or '.join(('key = ?' for x in excluded)) + ")" |
|
619 |
subq += ")" |
|
620 |
args += [domain] |
|
617 | 621 |
args += excluded |
618 | 622 |
append(subq) |
619 | 623 |
|
620 | 624 |
if opers: |
621 |
t = (("(a.key = ? and a.value %s ?)" % (o,)) for k, o, v in opers) |
|
622 |
subq = "(" + ' or '.join(t) + ")" |
|
625 |
subq = "exists (select 1 from attributes where serial = v.serial and domain = ? and " |
|
626 |
t = (("(key = ? and value %s ?)" % (o,)) for k, o, v in opers) |
|
627 |
subq += "(" + ' and '.join(t) + ")" |
|
628 |
subq += ")" |
|
629 |
args += [domain] |
|
623 | 630 |
for k, o, v in opers: |
624 | 631 |
args += [k, v] |
625 | 632 |
append(subq) |
... | ... | |
627 | 634 |
if not subqlist: |
628 | 635 |
return None, None |
629 | 636 |
|
630 |
subq = ' and a.domain = ? and ' + ' and '.join(subqlist) |
|
631 |
args = [domain] + args |
|
637 |
subq = ' and ' + ' and '.join(subqlist) |
|
632 | 638 |
|
633 | 639 |
return subq, args |
634 | 640 |
|
... | ... | |
726 | 732 |
nextling = strnextling(prefix) |
727 | 733 |
|
728 | 734 |
q = ("select distinct n.path, v.serial " |
729 |
"from attributes a, versions v, nodes n "
|
|
735 |
"from versions v, nodes n " |
|
730 | 736 |
"where v.serial = (select max(serial) " |
731 | 737 |
"from versions " |
732 | 738 |
"where node = v.node and mtime < ?) " |
... | ... | |
734 | 740 |
"and v.node in (select node " |
735 | 741 |
"from nodes " |
736 | 742 |
"where parent = ?) " |
737 |
"and a.serial = v.serial " |
|
738 | 743 |
"and n.node = v.node " |
739 | 744 |
"and n.path > ? and n.path < ?") |
740 | 745 |
args = [before, except_cluster, parent, start, nextling] |
Also available in: Unified diff