Revision 7759260d pithos/backends/lib/sqlalchemy/node.py

b/pithos/backends/lib/sqlalchemy/node.py
210 210
        """
211 211
        
212 212
        # Use LIKE for comparison to avoid MySQL problems with trailing spaces.
213
        path = path.replace('%', '\%')
214
        path = path.replace('_', '\_')
215
        s = select([self.nodes.c.node], self.nodes.c.path.like(path, escape='\\'))
213
        s = select([self.nodes.c.node], self.nodes.c.path.like(self.escape_like(path), escape='\\'))
216 214
        r = self.conn.execute(s)
217 215
        row = r.fetchone()
218 216
        r.close()
......
541 539
            self.versions.c.node == v.c.node)
542 540
        if before != inf:
543 541
            c1 = c1.where(self.versions.c.mtime < before)
544
        c2 = select([self.nodes.c.node], self.nodes.c.path.like(path + '%'))
542
        c2 = select([self.nodes.c.node], self.nodes.c.path.like(self.escape_like(path) + '%', escape='\\'))
545 543
        s = s.where(and_(v.c.serial == c1,
546 544
                         v.c.cluster != except_cluster,
547 545
                         v.c.node.in_(c2)))
......
744 742
        s = s.where(n.c.node == v.c.node)
745 743
        conj = []
746 744
        for x in pathq:
747
            conj.append(n.c.path.like(x + '%'))
745
            conj.append(n.c.path.like(self.escape_like(x) + '%', escape='\\'))
748 746
        if conj:
749 747
            s = s.where(or_(*conj))
750 748
        rp = self.conn.execute(s)
......
823 821
        s = s.where(and_(n.c.path > bindparam('start'), n.c.path < nextling))
824 822
        conj = []
825 823
        for x in pathq:
826
            conj.append(n.c.path.like(x + '%'))
824
            conj.append(n.c.path.like(self.escape_like(x) + '%', escape='\\'))
827 825
        
828 826
        if conj:
829 827
            s = s.where(or_(*conj))

Also available in: Unified diff