Bug 974291 - Correctly handle deleted items in getItemFlags. r=bnicholson
authorRichard Newman <rnewman@mozilla.com>
Wed, 19 Feb 2014 10:53:24 -0800
changeset 169646 575335837ed5e48fbbc50cc962d8041b941df63d
parent 169645 063b6736e07d9a90971247aa6186be200cfb3e04
child 169647 f43ffc6a3076fa8e8b9bc55e23e474752024818d
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbnicholson
bugs974291
milestone30.0a1
Bug 974291 - Correctly handle deleted items in getItemFlags. r=bnicholson
mobile/android/base/db/BrowserProvider.java
--- a/mobile/android/base/db/BrowserProvider.java
+++ b/mobile/android/base/db/BrowserProvider.java
@@ -697,27 +697,31 @@ public class BrowserProvider extends Tra
             // using disjoint flags, so we can simply use SUM and DISTINCT to get the
             // flags we need.
             // We turn parents into flags according to the three kinds, above.
             //
             // When this query is extended to support queries across multiple tables, simply
             // extend it to look like
             //
             // SELECT COALESCE((SELECT ...), 0) | COALESCE(...) | ...
+
+            final boolean includeDeleted = shouldShowDeleted(uri);
             final String query = "SELECT COALESCE(SUM(flag), 0) AS flags " +
                 "FROM ( SELECT DISTINCT CASE" +
                 " WHEN " + Bookmarks.PARENT + " = " + Bookmarks.FIXED_READING_LIST_ID +
                 " THEN " + Bookmarks.FLAG_READING +
 
                 " WHEN " + Bookmarks.PARENT + " = " + Bookmarks.FIXED_PINNED_LIST_ID +
                 " THEN " + Bookmarks.FLAG_PINNED +
 
                 " ELSE " + Bookmarks.FLAG_BOOKMARK +
                 " END flag " +
-                "FROM " + TABLE_BOOKMARKS + " WHERE " + Bookmarks.URL + " = ? " +
+                "FROM " + TABLE_BOOKMARKS + " WHERE " +
+                Bookmarks.URL + " = ? " +
+                (includeDeleted ? "" : ("AND " + Bookmarks.IS_DELETED + " = 0")) +
                 ")";
 
             return db.rawQuery(query, selectionArgs);
         }
 
         SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
         String limit = uri.getQueryParameter(BrowserContract.PARAM_LIMIT);
         String groupBy = null;