diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2021-09-18 12:38:35 +0200 |
---|---|---|
committer | Be <be@mixxx.org> | 2021-09-18 17:25:03 -0500 |
commit | 2d4f7d051b6449374cc09652e2dbdfaf2da231be (patch) | |
tree | 7bbeb82a0862d0f77579739430c91495be6fb685 /src | |
parent | 3a6bd19edcc92f757d047214d01442f99211f1c5 (diff) |
Fix parsing of duration seconds in search queries
Diffstat (limited to 'src')
-rw-r--r-- | src/library/searchquery.cpp | 2 | ||||
-rw-r--r-- | src/test/searchqueryparsertest.cpp | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/library/searchquery.cpp b/src/library/searchquery.cpp index 68437dc1e4..027c011f9c 100644 --- a/src/library/searchquery.cpp +++ b/src/library/searchquery.cpp @@ -12,7 +12,7 @@ #include "util/db/sqllikewildcards.h" namespace { -const QRegularExpression kDurationRegex(QStringLiteral("^(\\d*)(m|:)?([0-6]?\\d)?s?$")); +const QRegularExpression kDurationRegex(QStringLiteral("^(\\d+)(m|:)?([0-5]?\\d)?s?$")); // The ordering of operator alternatives separated by '|' is crucial to avoid incomplete // partial matches, e.g. by capturing "<" + "=" + <arg> instead of "<=" + <arg>! diff --git a/src/test/searchqueryparsertest.cpp b/src/test/searchqueryparsertest.cpp index ae333c6a67..25b9893e90 100644 --- a/src/test/searchqueryparsertest.cpp +++ b/src/test/searchqueryparsertest.cpp @@ -682,6 +682,12 @@ TEST_F(SearchQueryParserTest, HumanReadableDurationSearchWithOperators) { EXPECT_STREQ( qPrintable(QString("duration >= 63")), qPrintable(pQuery->toSql())); + + // Seconds out of range + pQuery = m_parser.parseQuery("duration:>=1:60", searchColumns, ""); + pTrack->setDuration(60); + EXPECT_FALSE(pQuery->match(pTrack)); + EXPECT_TRUE(pQuery->toSql().isEmpty()); } TEST_F(SearchQueryParserTest, HumanReadableDurationSearchwithRangeFilter) { |