From afdaddfc42e2c9dd3410b7a60cabd2a5d15f7b98 Mon Sep 17 00:00:00 2001 From: "mozilla.mano@sent.com" Date: Mon, 9 Apr 2007 17:24:37 -0700 Subject: [PATCH] Bug 376786 - Annotation-based queries are broken. r=dietrich. --- toolkit/components/places/src/nsNavHistory.cpp | 2 +- .../places/tests/unit/test_history.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/toolkit/components/places/src/nsNavHistory.cpp b/toolkit/components/places/src/nsNavHistory.cpp index 54385a538e27..e8bc3e260526 100644 --- a/toolkit/components/places/src/nsNavHistory.cpp +++ b/toolkit/components/places/src/nsNavHistory.cpp @@ -3242,7 +3242,7 @@ nsNavHistory::QueryToSelectClause(nsNavHistoryQuery* aQuery, // const if (aQuery->AnnotationIsNot()) aClause->AppendLiteral("NOT "); - aClause->AppendLiteral("EXISTS (SELECT id FROM moz_annos anno JOIN moz_anno_attributes annoname ON anno.anno_attribute_id = annoname.id WHERE anno.place_id = h.id AND annoname.name = "); + aClause->AppendLiteral("EXISTS (SELECT h.id FROM moz_annos anno JOIN moz_anno_attributes annoname ON anno.anno_attribute_id = annoname.id WHERE anno.place_id = h.id AND annoname.name = "); aClause->Append(paramString); aClause->AppendLiteral(") "); // annotation-based queries don't get the common conditions, so you get diff --git a/toolkit/components/places/tests/unit/test_history.js b/toolkit/components/places/tests/unit/test_history.js index 9dae043a4252..65695d44f30f 100644 --- a/toolkit/components/places/tests/unit/test_history.js +++ b/toolkit/components/places/tests/unit/test_history.js @@ -134,6 +134,24 @@ function run_test() { result = histsvc.executeQuery(query, options); result.root.containerOpen = true; do_check_eq(result.root.childCount, 2); + + // test annotation-based queries + var annos = Cc["@mozilla.org/browser/annotation-service;1"]. + getService(Ci.nsIAnnotationService); + annos.setAnnotationInt32(uri("http://mozilla.com/"), "testAnno", 0, 0, + Ci.nsIAnnotationService.EXPIRE_NEVER); + query.annotation = "testAnno"; + result = histsvc.executeQuery(query, options); + result.root.containerOpen = true; + do_check_eq(result.root.childCount, 1); + do_check_eq(result.root.getChild(0).uri, "http://mozilla.com/"); + + // test annotationIsNot + query.annotationIsNot = true; + result = histsvc.executeQuery(query, options); + result.root.containerOpen = true; + do_check_eq(result.root.childCount, 1); + do_check_eq(result.root.getChild(0).uri, "http://google.com/"); // by default, browser.history_expire_days is 9 do_check_true(!histsvc.historyDisabled);