Bug 512728 - searching for _v in filename to detect versions returns erroneous results
Summary: searching for _v in filename to detect versions returns erroneous results
Status: RESOLVED WORKSFORME
Alias: None
Product: digikam
Classification: Applications
Component: Searches-Advanced (other bugs)
Version First Reported In: 8.8.0
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-28 15:26 UTC by Steve Franks
Modified: 2025-12-25 10:54 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 9.0.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Franks 2025-11-28 15:26:37 UTC
When searching for versions (file_v1) the results include all files with v in their name, or extension.

SUMMARY
I accidentally ran BQM without changing the option to overwrite original file, so ended up with lots of _v1 files.
To find these I ran search with _v as filename to match. The results included .Avi .WAV and other files that have the letter v in their name, or extension, but not the underscore.

STEPS TO REPRODUCE
1.  Click on Search | New Advanced Search
2.   Enter _v in the filename | click on OK
3.  Cherck the results

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Steve Franks 2025-11-28 15:35:52 UTC
OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows:  11
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma:   Fedora 43
KDE Plasma Version : 6.5.3 
KDE Frameworks Version: 6.20.0
Qt Version:  6.10.1

ADDITIONAL INFORMATION
Comment 2 Maik Qualmann 2025-11-28 17:15:29 UTC
It's a "LIKE" database search. You need to escape such characters with a "\" at the front. So type: \_v

Maik
Comment 3 Maik Qualmann 2025-11-29 04:56:37 UTC
This is the old Bug 430147 from when we added the escape function to SQLite as well.

Maik
Comment 4 caulier.gilles 2025-11-29 05:19:52 UTC
Hi Maik,

Can we do the special characters escape automatically ? As i know, if we search file name with these characters must be prepared previously:

- _ : \_
- % : \%
- ' : ''
- " : ""
- ; : must be removed as it close an sql instruction.

I'm right ?
Gilles
Comment 5 Maik Qualmann 2025-11-29 06:58:18 UTC
There aren't many characters that need to be escaped in a LIKE SQL statement; see this MS Doc. The underscore is one of them.

https://learn.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql?view=sql-server-ver15#using-wildcard-characters-as-literals

The semicolon (";") as the end character is generally unproblematic, since we already encapsulate the search strings in the SQL statement.

I'll look into whether we can escape characters in SQL statements in general and whether there might be any side effects.

Maik