Merge pull request #1596 from mried/CaseInsensitiveSearch

Bugfix for case insensitive searches for a file path
This commit is contained in:
mried 2015-09-12 21:47:39 +02:00
commit 6bae8146bb
2 changed files with 8 additions and 4 deletions

View file

@ -92,9 +92,8 @@ class PathQuery(dbcore.FieldQuery):
return (path == self.file_path) or path.startswith(self.dir_path)
def col_clause(self):
file_blob = buffer(self.file_path)
if self.case_sensitive:
file_blob = buffer(self.file_path)
dir_blob = buffer(self.dir_path)
return '({0} = ?) || (substr({0}, 1, ?) = ?)'.format(self.field), \
(file_blob, len(dir_blob), dir_blob)
@ -102,8 +101,11 @@ class PathQuery(dbcore.FieldQuery):
escape = lambda m: self.escape_char + m.group(0)
dir_pattern = self.escape_re.sub(escape, self.dir_path)
dir_blob = buffer(dir_pattern + b'%')
return '({0} = ?) || ({0} LIKE ? ESCAPE ?)'.format(self.field), \
(file_blob, dir_blob, self.escape_char)
file_pattern = self.escape_re.sub(escape, self.file_path)
file_blob = buffer(file_pattern)
return '({0} LIKE ? ESCAPE ?) || ({0} LIKE ? ESCAPE ?)'.format(
self.field), (file_blob, self.escape_char, dir_blob,
self.escape_char)
# Library-specific field types.

View file

@ -45,6 +45,8 @@ Fixes:
written to files. Thanks to :user:`jdetrey`. :bug:`1303` :bug:`1589`
* :doc:`/plugins/replaygain`: Avoid a crash when the PyAudioTools backend
encounters an error. :bug:`1592`
* Case-insensitive path queries might have returned nothing because of a
wrong SQL query.
1.3.14 (August 2, 2015)