Revision 235a4227 snf-pithos-backend/pithos/backends/lib/sqlalchemy/dbworker.py

b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/dbworker.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
ESCAPE_CHAR = '@'
34 35

  
35 36
class DBWorker(object):
36 37
    """Database connection handler."""
......
42 43
        self.conn = wrapper.conn
43 44
        self.engine = wrapper.engine
44 45

  
45
    def escape_like(self, s):
46
        return s.replace('\\', '\\\\').replace('%', '\%').replace('_', '\_')
46
    def escape_like(self, s, escape_char=ESCAPE_CHAR):
47
        return (
48
                s
49
                .replace(escape_char, escape_char * 2)
50
                .replace('%', escape_char + '%')
51
                .replace('_', escape_char + '_')
52
        )

Also available in: Unified diff