Bug 1347248 - Change "nonexistent" for null and query to use CASE WHEN draft
authortiago <tiago.paez11@gmail.com>
Mon, 20 Mar 2017 02:03:02 +0100
changeset 501344 be247e71a2717c28589fdbdda78e9a26ae55738c
parent 501295 1b9293be51637f841275541d8991314ca56561a5
child 549838 7ce8a21ca74292839e5c426b8e15ecf417227405
push id49936
push userbmo:tiago.paez11@gmail.com
push dateMon, 20 Mar 2017 01:05:31 +0000
bugs1347248
milestone55.0a1
Bug 1347248 - Change "nonexistent" for null and query to use CASE WHEN MozReview-Commit-ID: I41bOputlIq
toolkit/components/places/Bookmarks.jsm
--- a/toolkit/components/places/Bookmarks.jsm
+++ b/toolkit/components/places/Bookmarks.jsm
@@ -1218,20 +1218,20 @@ function insertBookmark(item, parent) {
       let syncStatus =
         PlacesSyncUtils.bookmarks.determineInitialSyncStatus(item.source);
 
       // Insert the bookmark into the database.
       yield db.executeCached(
         `INSERT INTO moz_bookmarks (fk, type, parent, position, title,
                                     dateAdded, lastModified, guid,
                                     syncChangeCounter, syncStatus)
-         VALUES ((SELECT id FROM moz_places WHERE url_hash = hash(:url) AND url = :url), :type, :parent,
-                 :index, :title, :date_added, :last_modified, :guid,
-                 :syncChangeCounter, :syncStatus)
-        `, { url: item.hasOwnProperty("url") ? item.url.href : "nonexistent",
+         VALUES (CASE WHEN :url ISNULL THEN NULL ELSE (SELECT id FROM moz_places WHERE url_hash = hash(:url) AND url = :url) END,
+                 :type, :parent, :index, :title, :date_added, :last_modified,
+                 :guid, :syncChangeCounter, :syncStatus)
+        `, { url: item.hasOwnProperty("url") ? item.url.href : null,
              type: item.type, parent: parent._id, index: item.index,
              title: item.title, date_added: PlacesUtils.toPRTime(item.dateAdded),
              last_modified: PlacesUtils.toPRTime(item.lastModified), guid: item.guid,
              syncChangeCounter: syncChangeDelta, syncStatus });
 
       // Mark all affected separators as changed
       yield adjustSeparatorsSyncCounter(db, parent._id, item.index + 1, syncChangeDelta);