When no keywords to search, use an empty query selection that evaluates to "1".
This means that instead of building invalid SQL such as `WHERE (() OR ())` it will build `WHERE((1) OR (1))` which, while non-optimal, is at least valid. Fixes issue #560.
This commit is contained in:
parent
02c8fac906
commit
bd0e9e0a3c
@ -1,3 +1,7 @@
|
|||||||
|
### Upcoming Release
|
||||||
|
|
||||||
|
* Fix bug when entering only a space into the search dialog.
|
||||||
|
|
||||||
### 0.98 (2015-02-02)
|
### 0.98 (2015-02-02)
|
||||||
|
|
||||||
* Add opt-in crash reporting via ACRA
|
* Add opt-in crash reporting via ACRA
|
||||||
|
@ -614,15 +614,14 @@ public class AppProvider extends FDroidProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AppQuerySelection querySearch(String query) {
|
private AppQuerySelection querySearch(String query) {
|
||||||
final String[] columns = {
|
// Put in a Set to remove duplicates
|
||||||
getTableName() + ".id",
|
|
||||||
getTableName() + ".name",
|
|
||||||
getTableName() + ".summary",
|
|
||||||
getTableName() + ".description",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove duplicates, surround in % for wildcard searching
|
|
||||||
final Set<String> keywordSet = new HashSet<>(Arrays.asList(query.split("\\s")));
|
final Set<String> keywordSet = new HashSet<>(Arrays.asList(query.split("\\s")));
|
||||||
|
|
||||||
|
if (keywordSet.size() == 0) {
|
||||||
|
return new AppQuerySelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Surround each keyword in % for wildcard searching
|
||||||
final String[] keywords = new String[keywordSet.size()];
|
final String[] keywords = new String[keywordSet.size()];
|
||||||
int iKeyword = 0;
|
int iKeyword = 0;
|
||||||
for (final String keyword : keywordSet) {
|
for (final String keyword : keywordSet) {
|
||||||
@ -630,6 +629,13 @@ public class AppProvider extends FDroidProvider {
|
|||||||
iKeyword++;
|
iKeyword++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String[] columns = {
|
||||||
|
getTableName() + ".id",
|
||||||
|
getTableName() + ".name",
|
||||||
|
getTableName() + ".summary",
|
||||||
|
getTableName() + ".description",
|
||||||
|
};
|
||||||
|
|
||||||
// Build selection string and fill out keyword arguments
|
// Build selection string and fill out keyword arguments
|
||||||
final StringBuilder selection = new StringBuilder();
|
final StringBuilder selection = new StringBuilder();
|
||||||
final String[] selectionKeywords = new String[columns.length * keywords.length];
|
final String[] selectionKeywords = new String[columns.length * keywords.length];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user