-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow "" to filter for explicite empty fileds #1798
Changes from 14 commits
28b0b67
76a1119
b9e2be7
f54cf98
11ce5be
532c987
db56f9c
b817a32
dd1f85a
defb3b8
6811cf3
fc22212
5942d22
ef1d06a
82cb592
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
#include "util/memory.h" | ||
#include "library/crate/cratestorage.h" | ||
|
||
const QString kMissingFieldSearchTerm = "\"\""; // "" searches for an empty string | ||
|
||
QVariant getTrackValueForColumn(const TrackPointer& pTrack, const QString& column); | ||
|
||
class QueryNode { | ||
|
@@ -87,6 +89,23 @@ class TextFilterNode : public QueryNode { | |
QString m_argument; | ||
}; | ||
|
||
class NullOrEmptyTextFilterNode : public QueryNode { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have separate NullOrEmptyTextFilterNode/TextFilterNode and NoCrateFilterNode/FilterNode and the decision which one to use is done by the parser. But there is only one NumericFilterNode which does this decision internally. I understand the motivation behind this, i.e. to separate and modularize the code for different use cases. But now the design has become inconsistent and responsibilities are scattered across different levels of abstraction. |
||
public: | ||
NullOrEmptyTextFilterNode(const QSqlDatabase& database, | ||
const QStringList& sqlColumns) | ||
: m_database(database), | ||
m_sqlColumns(sqlColumns) { | ||
} | ||
|
||
bool match(const TrackPointer& pTrack) const override; | ||
QString toSql() const override; | ||
|
||
private: | ||
QSqlDatabase m_database; | ||
QStringList m_sqlColumns; | ||
}; | ||
|
||
|
||
class CrateFilterNode : public QueryNode { | ||
public: | ||
CrateFilterNode(const CrateStorage* pCrateStorage, | ||
|
@@ -102,6 +121,20 @@ class CrateFilterNode : public QueryNode { | |
mutable std::vector<TrackId> m_matchingTrackIds; | ||
}; | ||
|
||
class NoCrateFilterNode : public QueryNode { | ||
public: | ||
NoCrateFilterNode(const CrateStorage* pCrateStorage); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. explicit |
||
|
||
bool match(const TrackPointer& pTrack) const override; | ||
QString toSql() const override; | ||
|
||
private: | ||
const CrateStorage* m_pCrateStorage; | ||
QString m_crateNameLike; | ||
mutable bool m_matchInitialized; | ||
mutable std::vector<TrackId> m_matchingTrackIds; | ||
}; | ||
|
||
class NumericFilterNode : public QueryNode { | ||
public: | ||
NumericFilterNode(const QStringList& sqlColumns, const QString& argument); | ||
|
@@ -124,13 +157,24 @@ class NumericFilterNode : public QueryNode { | |
|
||
QStringList m_sqlColumns; | ||
bool m_bOperatorQuery; | ||
bool m_bNullQuery; | ||
QString m_operator; | ||
double m_dOperatorArgument; | ||
bool m_bRangeQuery; | ||
double m_dRangeLow; | ||
double m_dRangeHigh; | ||
}; | ||
|
||
class NullNumericFilterNode : public QueryNode { | ||
public: | ||
NullNumericFilterNode(const QStringList& sqlColumns); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. explicit |
||
|
||
bool match(const TrackPointer& pTrack) const override; | ||
QString toSql() const override; | ||
|
||
QStringList m_sqlColumns; | ||
}; | ||
|
||
class DurationFilterNode : public NumericFilterNode { | ||
public: | ||
DurationFilterNode(const QStringList& sqlColumns, const QString& argument); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit worried, because generally the size of this query's result if of the same magnitude as the size of the whole library.
The only way for preventing this would be to use an adaptive strategy depending on the actual contents of the crate tracks table, i.e. for deciding if most tracks are organized in crates or not. This comes at the cost of one or two additional queries for determining the sizes upfront to chose the optimum query that will return either a blacklist or a whitelist.
But the whole search thing does not scale very well, so let's just keep it as is without introducing more complexity.