@@ -61,7 +61,6 @@ SearchQueryParser::SearchQueryParser(TrackCollection* pTrackCollection)
61
61
m_fuzzyMatcher = QRegExp (QString (" ^~(%1)$" ).arg (m_allFilters.join (" |" )));
62
62
m_textFilterMatcher = QRegExp (QString (" ^-?(%1):(.*)$" ).arg (m_textFilters.join (" |" )));
63
63
m_exactTextMatcher = QRegExp (QString (" ^-?(%1):=(.*)$" ).arg (m_textFilters.join (" |" )));
64
- m_nullFilterMatcher = QRegExp (QString (" ^-?(%1):=0$" ).arg (m_textFilters.join (" |" )));
65
64
m_numericFilterMatcher = QRegExp (QString (" ^-?(%1):(.*)$" ).arg (m_numericFilters.join (" |" )));
66
65
m_specialFilterMatcher = QRegExp (QString (" ^[~-]?(%1):(.*)$" ).arg (m_specialFilters.join (" |" )));
67
66
}
@@ -122,7 +121,6 @@ void SearchQueryParser::parseTokens(QStringList tokens,
122
121
}
123
122
124
123
bool exact = m_exactTextMatcher.indexIn (token) != -1 ;
125
- bool nullMatch = m_nullFilterMatcher.indexIn (token) != -1 ;
126
124
bool negate = token.startsWith (kNegatePrefix );
127
125
std::unique_ptr<QueryNode> pNode;
128
126
@@ -139,24 +137,28 @@ void SearchQueryParser::parseTokens(QStringList tokens,
139
137
m_textFilterMatcher.cap (2 ), &tokens).trimmed ();
140
138
}
141
139
142
- if (!argument. isEmpty () ) {
143
- if (field == " crate " ) {
140
+ if (field == " crate " ) {
141
+ if (!argument. isEmpty () ) {
144
142
pNode = std::make_unique<CrateFilterNode>(
145
- &m_pTrackCollection->crates (), argument);
146
- } else if (exact) {
147
- if (nullMatch) {
148
- pNode = std::make_unique<SqlNode>(QString (
149
- " (%1 LIKE \"\" ) OR (%1 IS NULL)" ).arg (field));
150
- } else {
151
- pNode = std::make_unique<ExactFilterNode>(
152
- m_pTrackCollection->database (),
153
- m_fieldToSqlColumns[field], argument);
154
- }
143
+ &m_pTrackCollection->crates (), argument);
144
+ } else {
145
+ // TODO(gramanas) It should generate a query to
146
+ // match all the tracks that are not in a crate.
147
+ }
148
+ }
149
+ else if (!argument.isEmpty ()) {
150
+ if (exact) {
151
+ pNode = std::make_unique<ExactFilterNode>(
152
+ m_pTrackCollection->database (),
153
+ m_fieldToSqlColumns[field], argument);
155
154
} else {
156
155
pNode = std::make_unique<TextFilterNode>(
157
156
m_pTrackCollection->database (),
158
157
m_fieldToSqlColumns[field], argument);
159
158
}
159
+ } else {
160
+ pNode = std::make_unique<SqlNode>(QString (
161
+ " (%1 = \"\" ) OR (%1 IS NULL)" ).arg (field));
160
162
}
161
163
162
164
} else if (m_numericFilterMatcher.indexIn (token) != -1 ) {
0 commit comments