Bug 430147 - Search and escaping of database wildcard characters in filenames
Summary: Search and escaping of database wildcard characters in filenames
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Searches-Advanced (show other bugs)
Version: 7.1.0
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-08 11:51 UTC by Quincy
Modified: 2020-12-09 09:14 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 7.2.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Quincy 2020-12-08 11:51:45 UTC
I have filenames with underscores "_" in them separating information encoded in them e.g. "56_1607099331_270_3.tif" where the information is an id, a timestamp, a rotation angle and a camera id.

To tag those files properly I wanted to use the (mighty) search tool, but there are several things working differently than expected:
Using the "keyword search" (not the "advanced search") with "_270_" also yields results with filenames containing e.g. "12709". Obviously this field does not use usual wildcards for file managers ("*" and "?") but the database (in my case SQLite) ones for a "LIKE" query which are "_" and "%". This is not documented on https://docs.kde.org/trunk5/en/extragear-graphics/digikam/using-digikam.html#using-mainwindow-searchesview, instead it is stated that special characters are ignored.
It is not possible (or I did not find how) to escape those characters to search for a "real" underscore e.g. escaping with "\" (even multiple ones) does not work.
The same applies for the advanced search with the "File name" field.

Thanks in advance for having a look into that issue and the great work on this software.
Comment 1 Maik Qualmann 2020-12-08 12:22:52 UTC
The search works when I search for "\_270\_" (without quotation marks).

Maik
Comment 2 Maik Qualmann 2020-12-08 12:27:33 UTC
Ok, it works with MySQL but not with SQLite.

Maik
Comment 3 Maik Qualmann 2020-12-08 19:33:27 UTC
Git commit 5e87ffe78349f56a6da3f8ddee62095074d725ff by Maik Qualmann.
Committed on 08/12/2020 at 19:32.
Pushed by mqualmann into branch 'master'.

add escape character '\' to LIKE search with SQLite
FIXED-IN: 7.2.0

M  +2    -1    NEWS
M  +12   -1    core/libs/database/item/query/fieldquerybuilder.cpp

https://invent.kde.org/graphics/digikam/commit/5e87ffe78349f56a6da3f8ddee62095074d725ff
Comment 4 Quincy 2020-12-09 09:14:21 UTC
Thanks for the quick fix.

So the wildcards "_" and "%" will still be usable and have to be escaped if one needs to use them as literal?

Could one please update the documentation accordingly as wildcards may be of nice use, but I think most people will try "*" and "?" otherwise if at all.