PathQuery: use substr() instead of instr()

substr() is only available in SQLite 3.7.15+, which is not available yet
on Debian stable, CentOS & co. Use substr() instead.
This commit is contained in:
Bruno Cauet 2015-02-18 18:52:22 +01:00
parent 83e34322e9
commit 6fc678e947

View file

@ -73,8 +73,8 @@ class PathQuery(dbcore.FieldQuery):
if not self._is_windows:
dir_blob = buffer(self.dir_path)
return '({0} = ?) || (instr({0}, ?) = 1)'.format(self.field), \
(file_blob, dir_blob)
return '({0} = ?) || (substr({0}, 1, ?) = ?)'.format(self.field), \
(file_blob, len(dir_blob), dir_blob)
escape = lambda m: self.escape_char + m.group(0)
dir_pattern = self.escape_re.sub(escape, self.dir_path)