Bug 794631 - Don't add useless WHERE clauses to empty filter queries. r=lucasr

This commit is contained in:
Margaret Leibovic 2012-09-26 14:27:06 -07:00
parent c7bf532b7d
commit bc465e56c8

View File

@ -24,6 +24,7 @@ import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.net.Uri; import android.net.Uri;
import android.provider.Browser; import android.provider.Browser;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -138,13 +139,15 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
// The combined history/bookmarks selection queries for sites with a url or title containing // The combined history/bookmarks selection queries for sites with a url or title containing
// the constraint string(s), treating space-separated words as separate constraints // the constraint string(s), treating space-separated words as separate constraints
String[] constraintWords = constraint.toString().split(" "); if (!TextUtils.isEmpty(constraint)) {
for (int i = 0; i < constraintWords.length; i++) { String[] constraintWords = constraint.toString().split(" ");
selection = DBUtils.concatenateWhere(selection, "(" + Combined.URL + " LIKE ? OR " + for (int i = 0; i < constraintWords.length; i++) {
Combined.TITLE + " LIKE ?)"); selection = DBUtils.concatenateWhere(selection, "(" + Combined.URL + " LIKE ? OR " +
String constraintWord = "%" + constraintWords[i] + "%"; Combined.TITLE + " LIKE ?)");
selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, String constraintWord = "%" + constraintWords[i] + "%";
new String[] { constraintWord, constraintWord }); selectionArgs = DBUtils.appendSelectionArgs(selectionArgs,
new String[] { constraintWord, constraintWord });
}
} }
if (urlFilter != null) { if (urlFilter != null) {