зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1060839 - Use template strings for multi-line SQL statements in tests. r=ttaubert
This commit is contained in:
Родитель
7b2b178fd6
Коммит
d1fb0ede0b
|
@ -26,9 +26,9 @@ let bookmarksObserver = {
|
|||
|
||||
// Ensure that we've created a guid for this item.
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT guid "
|
||||
+ "FROM moz_bookmarks "
|
||||
+ "WHERE id = :item_id "
|
||||
`SELECT guid
|
||||
FROM moz_bookmarks
|
||||
WHERE id = :item_id`
|
||||
);
|
||||
stmt.params.item_id = id;
|
||||
do_check_true(stmt.executeStep());
|
||||
|
|
|
@ -28,9 +28,9 @@ function check_uri_keyword(aURI, aKeyword)
|
|||
function check_orphans()
|
||||
{
|
||||
stmt = DBConn().createStatement(
|
||||
"SELECT id FROM moz_keywords k WHERE NOT EXISTS ("
|
||||
+ "SELECT id FROM moz_bookmarks WHERE keyword_id = k.id "
|
||||
+ ")"
|
||||
`SELECT id FROM moz_keywords k WHERE NOT EXISTS (
|
||||
SELECT id FROM moz_bookmarks WHERE keyword_id = k.id
|
||||
)`
|
||||
);
|
||||
try {
|
||||
do_check_false(stmt.executeStep());
|
||||
|
@ -40,9 +40,9 @@ function check_orphans()
|
|||
|
||||
print("Check there are no orphan database entries");
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT b.id FROM moz_bookmarks b "
|
||||
+ "LEFT JOIN moz_keywords k ON b.keyword_id = k.id "
|
||||
+ "WHERE keyword_id NOTNULL AND k.id ISNULL"
|
||||
`SELECT b.id FROM moz_bookmarks b
|
||||
LEFT JOIN moz_keywords k ON b.keyword_id = k.id
|
||||
WHERE keyword_id NOTNULL AND k.id ISNULL`
|
||||
);
|
||||
try {
|
||||
do_check_false(stmt.executeStep());
|
||||
|
|
|
@ -34,8 +34,8 @@ var conn = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase).DBConnectio
|
|||
function getColumn(table, column, fromColumnName, fromColumnValue)
|
||||
{
|
||||
var stmt = conn.createStatement(
|
||||
"SELECT " + column + " FROM " + table + " WHERE " + fromColumnName + "=:val " +
|
||||
"LIMIT 1");
|
||||
`SELECT ${column} FROM ${table} WHERE ${fromColumnName} = :val
|
||||
LIMIT 1`);
|
||||
try {
|
||||
stmt.params.val = fromColumnValue;
|
||||
stmt.executeStep();
|
||||
|
|
|
@ -48,10 +48,10 @@ var conn = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase).DBConnectio
|
|||
*/
|
||||
function getColumn(table, column, fromColumnName, fromColumnValue)
|
||||
{
|
||||
let sql = "SELECT " + column + " " +
|
||||
"FROM " + table + " " +
|
||||
"WHERE " + fromColumnName + " = :val " +
|
||||
"LIMIT 1";
|
||||
let sql = `SELECT ${column}
|
||||
FROM ${table}
|
||||
WHERE ${fromColumnName} = :val
|
||||
LIMIT 1`;
|
||||
let stmt = conn.createStatement(sql);
|
||||
try {
|
||||
stmt.params.val = fromColumnValue;
|
||||
|
|
|
@ -102,7 +102,7 @@ function fieldForUrl(aURI, aFieldName, aCallback)
|
|||
let url = aURI instanceof Ci.nsIURI ? aURI.spec : aURI;
|
||||
let stmt = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
|
||||
.DBConnection.createAsyncStatement(
|
||||
"SELECT " + aFieldName + " FROM moz_places WHERE url = :page_url"
|
||||
`SELECT ${aFieldName} FROM moz_places WHERE url = :page_url`
|
||||
);
|
||||
stmt.params.page_url = url;
|
||||
stmt.executeAsync({
|
||||
|
@ -351,9 +351,9 @@ function checkGuidForURI(aURI, aGUID) {
|
|||
*/
|
||||
function doGetGuidForURI(aURI) {
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT guid "
|
||||
+ "FROM moz_places "
|
||||
+ "WHERE url = :url "
|
||||
`SELECT guid
|
||||
FROM moz_places
|
||||
WHERE url = :url`
|
||||
);
|
||||
stmt.params.url = aURI.spec;
|
||||
ok(stmt.executeStep(), "Check get guid for uri from moz_places");
|
||||
|
|
|
@ -54,9 +54,9 @@ add_task(function test_annos_expire_session() {
|
|||
let deferred = Promise.defer();
|
||||
waitForConnectionClosed(function() {
|
||||
let stmt = DBConn(true).createAsyncStatement(
|
||||
"SELECT id FROM moz_annos "
|
||||
+ "UNION ALL "
|
||||
+ "SELECT id FROM moz_items_annos "
|
||||
`SELECT id FROM moz_annos
|
||||
UNION ALL
|
||||
SELECT id FROM moz_items_annos`
|
||||
);
|
||||
stmt.executeAsync({
|
||||
handleResult: function(aResultSet) {
|
||||
|
|
|
@ -312,9 +312,9 @@ function visits_in_database(aURI)
|
|||
{
|
||||
let url = aURI instanceof Ci.nsIURI ? aURI.spec : aURI;
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT count(*) FROM moz_historyvisits v "
|
||||
+ "JOIN moz_places h ON h.id = v.place_id "
|
||||
+ "WHERE url = :url"
|
||||
`SELECT count(*) FROM moz_historyvisits v
|
||||
JOIN moz_places h ON h.id = v.place_id
|
||||
WHERE url = :url`
|
||||
);
|
||||
stmt.params.url = url;
|
||||
try {
|
||||
|
@ -689,9 +689,9 @@ function do_get_guid_for_uri(aURI,
|
|||
aStack = Components.stack.caller;
|
||||
}
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT guid "
|
||||
+ "FROM moz_places "
|
||||
+ "WHERE url = :url "
|
||||
`SELECT guid
|
||||
FROM moz_places
|
||||
WHERE url = :url`
|
||||
);
|
||||
stmt.params.url = aURI.spec;
|
||||
do_check_true(stmt.executeStep(), aStack);
|
||||
|
@ -736,9 +736,9 @@ function do_get_guid_for_bookmark(aId,
|
|||
aStack = Components.stack.caller;
|
||||
}
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT guid "
|
||||
+ "FROM moz_bookmarks "
|
||||
+ "WHERE id = :item_id "
|
||||
`SELECT guid
|
||||
FROM moz_bookmarks
|
||||
WHERE id = :item_id`
|
||||
);
|
||||
stmt.params.item_id = aId;
|
||||
do_check_true(stmt.executeStep(), aStack);
|
||||
|
|
|
@ -57,13 +57,13 @@ function test_initial_state()
|
|||
|
||||
// There should be five item annotations for a bookmark guid.
|
||||
stmt = db.createStatement(
|
||||
"SELECT content AS guid, item_id "
|
||||
+ "FROM moz_items_annos "
|
||||
+ "WHERE anno_attribute_id = ( "
|
||||
+ "SELECT id "
|
||||
+ "FROM moz_anno_attributes "
|
||||
+ "WHERE name = :attr_name "
|
||||
+ ") "
|
||||
`SELECT content AS guid, item_id
|
||||
FROM moz_items_annos
|
||||
WHERE anno_attribute_id = (
|
||||
SELECT id
|
||||
FROM moz_anno_attributes
|
||||
WHERE name = :attr_name
|
||||
)`
|
||||
);
|
||||
stmt.params.attr_name = kGuidAnnotationName;
|
||||
while (stmt.executeStep()) {
|
||||
|
@ -76,13 +76,13 @@ function test_initial_state()
|
|||
|
||||
// There should be five item annotations for a place guid.
|
||||
stmt = db.createStatement(
|
||||
"SELECT content AS guid, place_id "
|
||||
+ "FROM moz_annos "
|
||||
+ "WHERE anno_attribute_id = ( "
|
||||
+ "SELECT id "
|
||||
+ "FROM moz_anno_attributes "
|
||||
+ "WHERE name = :attr_name "
|
||||
+ ") "
|
||||
`SELECT content AS guid, place_id
|
||||
FROM moz_annos
|
||||
WHERE anno_attribute_id = (
|
||||
SELECT id
|
||||
FROM moz_anno_attributes
|
||||
WHERE name = :attr_name
|
||||
)`
|
||||
);
|
||||
stmt.params.attr_name = kGuidAnnotationName;
|
||||
while (stmt.executeStep()) {
|
||||
|
@ -104,8 +104,8 @@ function test_moz_bookmarks_guid_exists()
|
|||
{
|
||||
// This will throw if the column does not exist
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT guid "
|
||||
+ "FROM moz_bookmarks "
|
||||
`SELECT guid
|
||||
FROM moz_bookmarks`
|
||||
);
|
||||
stmt.finalize();
|
||||
|
||||
|
@ -116,8 +116,8 @@ function test_bookmark_guids_non_null()
|
|||
{
|
||||
// First, sanity check that we have a non-zero amount of bookmarks.
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) "
|
||||
+ "FROM moz_bookmarks "
|
||||
`SELECT COUNT(1)
|
||||
FROM moz_bookmarks`
|
||||
);
|
||||
do_check_true(stmt.executeStep());
|
||||
do_check_neq(stmt.getInt32(0), 0);
|
||||
|
@ -125,9 +125,9 @@ function test_bookmark_guids_non_null()
|
|||
|
||||
// Now, make sure we have no NULL guid entry.
|
||||
stmt = DBConn().createStatement(
|
||||
"SELECT guid "
|
||||
+ "FROM moz_bookmarks "
|
||||
+ "WHERE guid IS NULL "
|
||||
`SELECT guid
|
||||
FROM moz_bookmarks
|
||||
WHERE guid IS NULL`
|
||||
);
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
@ -138,10 +138,10 @@ function test_bookmark_guid_annotation_imported()
|
|||
{
|
||||
// Make sure we have the imported guid; not a newly generated one.
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT id "
|
||||
+ "FROM moz_bookmarks "
|
||||
+ "WHERE guid = :guid "
|
||||
+ "AND id = :item_id "
|
||||
`SELECT id
|
||||
FROM moz_bookmarks
|
||||
WHERE guid = :guid
|
||||
AND id = :item_id`
|
||||
);
|
||||
let validGuids = 0;
|
||||
let seenGuids = [];
|
||||
|
@ -173,13 +173,13 @@ function test_bookmark_guid_annotation_imported()
|
|||
function test_bookmark_guid_annotation_removed()
|
||||
{
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) "
|
||||
+ "FROM moz_items_annos "
|
||||
+ "WHERE anno_attribute_id = ( "
|
||||
+ "SELECT id "
|
||||
+ "FROM moz_anno_attributes "
|
||||
+ "WHERE name = :attr_name "
|
||||
+ ") "
|
||||
`SELECT COUNT(1)
|
||||
FROM moz_items_annos
|
||||
WHERE anno_attribute_id = (
|
||||
SELECT id
|
||||
FROM moz_anno_attributes
|
||||
WHERE name = :attr_name
|
||||
)`
|
||||
);
|
||||
stmt.params.attr_name = kGuidAnnotationName;
|
||||
do_check_true(stmt.executeStep());
|
||||
|
@ -193,8 +193,8 @@ function test_moz_places_guid_exists()
|
|||
{
|
||||
// This will throw if the column does not exist
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT guid "
|
||||
+ "FROM moz_places "
|
||||
`SELECT guid
|
||||
FROM moz_places`
|
||||
);
|
||||
stmt.finalize();
|
||||
|
||||
|
@ -205,8 +205,8 @@ function test_place_guids_non_null()
|
|||
{
|
||||
// First, sanity check that we have a non-zero amount of places.
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) "
|
||||
+ "FROM moz_places "
|
||||
`SELECT COUNT(1)
|
||||
FROM moz_places`
|
||||
);
|
||||
do_check_true(stmt.executeStep());
|
||||
do_check_neq(stmt.getInt32(0), 0);
|
||||
|
@ -214,9 +214,9 @@ function test_place_guids_non_null()
|
|||
|
||||
// Now, make sure we have no NULL guid entry.
|
||||
stmt = DBConn().createStatement(
|
||||
"SELECT guid "
|
||||
+ "FROM moz_places "
|
||||
+ "WHERE guid IS NULL "
|
||||
`SELECT guid
|
||||
FROM moz_places
|
||||
WHERE guid IS NULL`
|
||||
);
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
@ -227,10 +227,10 @@ function test_place_guid_annotation_imported()
|
|||
{
|
||||
// Make sure we have the imported guid; not a newly generated one.
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT id "
|
||||
+ "FROM moz_places "
|
||||
+ "WHERE guid = :guid "
|
||||
+ "AND id = :item_id "
|
||||
`SELECT id
|
||||
FROM moz_places
|
||||
WHERE guid = :guid
|
||||
AND id = :item_id`
|
||||
);
|
||||
let validGuids = 0;
|
||||
let seenGuids = [];
|
||||
|
@ -262,13 +262,13 @@ function test_place_guid_annotation_imported()
|
|||
function test_place_guid_annotation_removed()
|
||||
{
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) "
|
||||
+ "FROM moz_annos "
|
||||
+ "WHERE anno_attribute_id = ( "
|
||||
+ "SELECT id "
|
||||
+ "FROM moz_anno_attributes "
|
||||
+ "WHERE name = :attr_name "
|
||||
+ ") "
|
||||
`SELECT COUNT(1)
|
||||
FROM moz_annos
|
||||
WHERE anno_attribute_id = (
|
||||
SELECT id
|
||||
FROM moz_anno_attributes
|
||||
WHERE name = :attr_name
|
||||
)`
|
||||
);
|
||||
stmt.params.attr_name = kGuidAnnotationName;
|
||||
do_check_true(stmt.executeStep());
|
||||
|
@ -282,8 +282,8 @@ function test_moz_hosts()
|
|||
{
|
||||
// This will throw if the column does not exist
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT host, frecency, typed, prefix "
|
||||
+ "FROM moz_hosts "
|
||||
`SELECT host, frecency, typed, prefix
|
||||
FROM moz_hosts`
|
||||
);
|
||||
stmt.finalize();
|
||||
|
||||
|
@ -292,10 +292,10 @@ function test_moz_hosts()
|
|||
// check the number of entries in moz_hosts equals the number of
|
||||
// unique rev_host in moz_places
|
||||
stmt = DBConn().createAsyncStatement(
|
||||
"SELECT (SELECT COUNT(host) FROM moz_hosts), " +
|
||||
"(SELECT COUNT(DISTINCT rev_host) " +
|
||||
"FROM moz_places " +
|
||||
"WHERE LENGTH(rev_host) > 1)");
|
||||
`SELECT (SELECT COUNT(host) FROM moz_hosts),
|
||||
(SELECT COUNT(DISTINCT rev_host)
|
||||
FROM moz_places
|
||||
WHERE LENGTH(rev_host) > 1)`);
|
||||
try {
|
||||
stmt.executeAsync({
|
||||
handleResult: function (aResult) {
|
||||
|
|
|
@ -30,9 +30,9 @@ function test_initial_state()
|
|||
|
||||
// There should be a non-zero amount of bookmarks without a guid.
|
||||
stmt = db.createStatement(
|
||||
"SELECT COUNT(1) "
|
||||
+ "FROM moz_bookmarks "
|
||||
+ "WHERE guid IS NULL "
|
||||
`SELECT COUNT(1)
|
||||
FROM moz_bookmarks
|
||||
WHERE guid IS NULL`
|
||||
);
|
||||
do_check_true(stmt.executeStep());
|
||||
do_check_neq(stmt.getInt32(0), 0);
|
||||
|
@ -40,9 +40,9 @@ function test_initial_state()
|
|||
|
||||
// There should be a non-zero amount of places without a guid.
|
||||
stmt = db.createStatement(
|
||||
"SELECT COUNT(1) "
|
||||
+ "FROM moz_places "
|
||||
+ "WHERE guid IS NULL "
|
||||
`SELECT COUNT(1)
|
||||
FROM moz_places
|
||||
WHERE guid IS NULL`
|
||||
);
|
||||
do_check_true(stmt.executeStep());
|
||||
do_check_neq(stmt.getInt32(0), 0);
|
||||
|
@ -60,8 +60,8 @@ function test_bookmark_guids_non_null()
|
|||
// First, sanity check that we have a non-zero amount of bookmarks. If
|
||||
// migration failed, we would have zero.
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) "
|
||||
+ "FROM moz_bookmarks "
|
||||
`SELECT COUNT(1)
|
||||
FROM moz_bookmarks`
|
||||
);
|
||||
do_check_true(stmt.executeStep());
|
||||
do_check_neq(stmt.getInt32(0), 0);
|
||||
|
@ -69,9 +69,9 @@ function test_bookmark_guids_non_null()
|
|||
|
||||
// Now, make sure we have no NULL guid entries.
|
||||
stmt = DBConn().createStatement(
|
||||
"SELECT guid "
|
||||
+ "FROM moz_bookmarks "
|
||||
+ "WHERE guid IS NULL "
|
||||
`SELECT guid
|
||||
FROM moz_bookmarks
|
||||
WHERE guid IS NULL`
|
||||
);
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
@ -83,8 +83,8 @@ function test_place_guids_non_null()
|
|||
// First, sanity check that we have a non-zero amount of places. If migration
|
||||
// failed, we would have zero.
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) "
|
||||
+ "FROM moz_places "
|
||||
`SELECT COUNT(1)
|
||||
FROM moz_places`
|
||||
);
|
||||
do_check_true(stmt.executeStep());
|
||||
do_check_neq(stmt.getInt32(0), 0);
|
||||
|
@ -92,9 +92,9 @@ function test_place_guids_non_null()
|
|||
|
||||
// Now, make sure we have no NULL guid entry.
|
||||
stmt = DBConn().createStatement(
|
||||
"SELECT guid "
|
||||
+ "FROM moz_places "
|
||||
+ "WHERE guid IS NULL "
|
||||
`SELECT guid
|
||||
FROM moz_places
|
||||
WHERE guid IS NULL`
|
||||
);
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
|
|
@ -13,10 +13,10 @@ const kGuidAnnotationName = "placesInternal/GUID";
|
|||
|
||||
function getTotalGuidAnnotationsCount(aStorageConnection) {
|
||||
stmt = aStorageConnection.createStatement(
|
||||
"SELECT count(*) "
|
||||
+ "FROM moz_items_annos a "
|
||||
+ "JOIN moz_anno_attributes b ON a.anno_attribute_id = b.id "
|
||||
+ "WHERE b.name = :attr_name"
|
||||
`SELECT count(*)
|
||||
FROM moz_items_annos a
|
||||
JOIN moz_anno_attributes b ON a.anno_attribute_id = b.id
|
||||
WHERE b.name = :attr_name`
|
||||
);
|
||||
try {
|
||||
stmt.params.attr_name = kGuidAnnotationName;
|
||||
|
|
|
@ -117,12 +117,12 @@ function checkDB(data){
|
|||
referrer: referrer},
|
||||
function() {
|
||||
// Get all pages visited from the original typed one
|
||||
var sql = "SELECT url FROM moz_historyvisits " +
|
||||
"JOIN moz_places h ON h.id = place_id " +
|
||||
"WHERE from_visit IN " +
|
||||
"(SELECT v.id FROM moz_historyvisits v " +
|
||||
"JOIN moz_places p ON p.id = v.place_id " +
|
||||
"WHERE p.url = ?1)";
|
||||
var sql = `SELECT url FROM moz_historyvisits
|
||||
JOIN moz_places h ON h.id = place_id
|
||||
WHERE from_visit IN
|
||||
(SELECT v.id FROM moz_historyvisits v
|
||||
JOIN moz_places p ON p.id = v.place_id
|
||||
WHERE p.url = ?1)`;
|
||||
var stmt = mDBConn.createStatement(sql);
|
||||
stmt.bindByIndex(0, typedURI.spec);
|
||||
|
||||
|
|
|
@ -135,9 +135,9 @@ function do_check_title_for_uri(aURI,
|
|||
{
|
||||
let stack = Components.stack.caller;
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT title " +
|
||||
"FROM moz_places " +
|
||||
"WHERE url = :url "
|
||||
`SELECT title
|
||||
FROM moz_places
|
||||
WHERE url = :url`
|
||||
);
|
||||
stmt.params.url = aURI.spec;
|
||||
do_check_true(stmt.executeStep(), stack);
|
||||
|
@ -470,9 +470,9 @@ function test_invalid_referrerURI_ignored()
|
|||
|
||||
// Check to make sure from_visit is zero in database.
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT from_visit " +
|
||||
"FROM moz_historyvisits " +
|
||||
"WHERE id = :visit_id"
|
||||
`SELECT from_visit
|
||||
FROM moz_historyvisits
|
||||
WHERE id = :visit_id`
|
||||
);
|
||||
stmt.params.visit_id = placeInfo.visits[0].visitId;
|
||||
do_check_true(stmt.executeStep());
|
||||
|
@ -503,9 +503,9 @@ function test_nonnsIURI_referrerURI_ignored()
|
|||
|
||||
// Check to make sure from_visit is zero in database.
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT from_visit " +
|
||||
"FROM moz_historyvisits " +
|
||||
"WHERE id = :visit_id"
|
||||
`SELECT from_visit
|
||||
FROM moz_historyvisits
|
||||
WHERE id = :visit_id`
|
||||
);
|
||||
stmt.params.visit_id = placeInfo.visits[0].visitId;
|
||||
do_check_true(stmt.executeStep());
|
||||
|
@ -562,10 +562,10 @@ function test_old_referrer_ignored()
|
|||
// database to be sure.
|
||||
do_check_eq(placeInfo.visits[0].referrerURI, null);
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) AS count " +
|
||||
"FROM moz_historyvisits " +
|
||||
"WHERE place_id = (SELECT id FROM moz_places WHERE url = :page_url) " +
|
||||
"AND from_visit = 0 "
|
||||
`SELECT COUNT(1) AS count
|
||||
FROM moz_historyvisits
|
||||
WHERE place_id = (SELECT id FROM moz_places WHERE url = :page_url)
|
||||
AND from_visit = 0`
|
||||
);
|
||||
stmt.params.page_url = place.uri.spec;
|
||||
do_check_true(stmt.executeStep());
|
||||
|
@ -758,12 +758,12 @@ function test_properties_saved()
|
|||
|
||||
// mozIVisitInfo::date
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) AS count " +
|
||||
"FROM moz_places h " +
|
||||
"JOIN moz_historyvisits v " +
|
||||
"ON h.id = v.place_id " +
|
||||
"WHERE h.url = :page_url " +
|
||||
"AND v.visit_date = :visit_date "
|
||||
`SELECT COUNT(1) AS count
|
||||
FROM moz_places h
|
||||
JOIN moz_historyvisits v
|
||||
ON h.id = v.place_id
|
||||
WHERE h.url = :page_url
|
||||
AND v.visit_date = :visit_date`
|
||||
);
|
||||
stmt.params.page_url = uri.spec;
|
||||
stmt.params.visit_date = visit.visitDate;
|
||||
|
@ -773,12 +773,12 @@ function test_properties_saved()
|
|||
|
||||
// mozIVisitInfo::transitionType
|
||||
stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) AS count " +
|
||||
"FROM moz_places h " +
|
||||
"JOIN moz_historyvisits v " +
|
||||
"ON h.id = v.place_id " +
|
||||
"WHERE h.url = :page_url " +
|
||||
"AND v.visit_type = :transition_type "
|
||||
`SELECT COUNT(1) AS count
|
||||
FROM moz_places h
|
||||
JOIN moz_historyvisits v
|
||||
ON h.id = v.place_id
|
||||
WHERE h.url = :page_url
|
||||
AND v.visit_type = :transition_type`
|
||||
);
|
||||
stmt.params.page_url = uri.spec;
|
||||
stmt.params.transition_type = visit.transitionType;
|
||||
|
@ -788,10 +788,10 @@ function test_properties_saved()
|
|||
|
||||
// mozIPlaceInfo::title
|
||||
stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) AS count " +
|
||||
"FROM moz_places h " +
|
||||
"WHERE h.url = :page_url " +
|
||||
"AND h.title = :title "
|
||||
`SELECT COUNT(1) AS count
|
||||
FROM moz_places h
|
||||
WHERE h.url = :page_url
|
||||
AND h.title = :title`
|
||||
);
|
||||
stmt.params.page_url = uri.spec;
|
||||
stmt.params.title = placeInfo.title;
|
||||
|
@ -863,14 +863,14 @@ function test_referrer_saved()
|
|||
do_check_true(places[0].uri.equals(visit.referrerURI));
|
||||
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT COUNT(1) AS count " +
|
||||
"FROM moz_historyvisits " +
|
||||
"WHERE place_id = (SELECT id FROM moz_places WHERE url = :page_url) " +
|
||||
"AND from_visit = ( " +
|
||||
"SELECT id " +
|
||||
"FROM moz_historyvisits " +
|
||||
"WHERE place_id = (SELECT id FROM moz_places WHERE url = :referrer) " +
|
||||
") "
|
||||
`SELECT COUNT(1) AS count
|
||||
FROM moz_historyvisits
|
||||
WHERE place_id = (SELECT id FROM moz_places WHERE url = :page_url)
|
||||
AND from_visit = (
|
||||
SELECT id
|
||||
FROM moz_historyvisits
|
||||
WHERE place_id = (SELECT id FROM moz_places WHERE url = :referrer)
|
||||
)`
|
||||
);
|
||||
stmt.params.page_url = uri.spec;
|
||||
stmt.params.referrer = visit.referrerURI.spec;
|
||||
|
|
|
@ -113,8 +113,8 @@ add_task(function test_history_removeAllPages()
|
|||
stmt.finalize();
|
||||
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h WHERE h.frecency < 0 " +
|
||||
"AND EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1");
|
||||
`SELECT h.id FROM moz_places h WHERE h.frecency < 0
|
||||
AND EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1`);
|
||||
do_check_true(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
|
@ -132,36 +132,36 @@ add_task(function test_history_removeAllPages()
|
|||
|
||||
// Check that all moz_places entries except bookmarks and place: have been removed
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h WHERE SUBSTR(h.url, 1, 6) <> 'place:' "+
|
||||
"AND NOT EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1");
|
||||
`SELECT h.id FROM moz_places h WHERE SUBSTR(h.url, 1, 6) <> 'place:'
|
||||
AND NOT EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) LIMIT 1`);
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that we only have favicons for retained places
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT f.id FROM moz_favicons f WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE favicon_id = f.id) LIMIT 1");
|
||||
`SELECT f.id FROM moz_favicons f WHERE NOT EXISTS
|
||||
(SELECT id FROM moz_places WHERE favicon_id = f.id) LIMIT 1`);
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that we only have annotations for retained places
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT a.id FROM moz_annos a WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE id = a.place_id) LIMIT 1");
|
||||
`SELECT a.id FROM moz_annos a WHERE NOT EXISTS
|
||||
(SELECT id FROM moz_places WHERE id = a.place_id) LIMIT 1`);
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that we only have inputhistory for retained places
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT i.place_id FROM moz_inputhistory i WHERE NOT EXISTS " +
|
||||
"(SELECT id FROM moz_places WHERE id = i.place_id) LIMIT 1");
|
||||
`SELECT i.place_id FROM moz_inputhistory i WHERE NOT EXISTS
|
||||
(SELECT id FROM moz_places WHERE id = i.place_id) LIMIT 1`);
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
||||
// Check that place:uris have frecency 0
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h " +
|
||||
"WHERE SUBSTR(h.url, 1, 6) = 'place:' AND h.frecency <> 0 LIMIT 1");
|
||||
`SELECT h.id FROM moz_places h
|
||||
WHERE SUBSTR(h.url, 1, 6) = 'place:' AND h.frecency <> 0 LIMIT 1`);
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
});
|
||||
|
|
|
@ -16,9 +16,9 @@ XPCOMUtils.defineLazyServiceGetter(this, "gHistory",
|
|||
function isHostInMozPlaces(aURI)
|
||||
{
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT url "
|
||||
+ "FROM moz_places "
|
||||
+ "WHERE url = :host"
|
||||
`SELECT url
|
||||
FROM moz_places
|
||||
WHERE url = :host`
|
||||
);
|
||||
let result = false;
|
||||
stmt.params.host = aURI.spec;
|
||||
|
@ -35,10 +35,10 @@ function isHostInMozPlaces(aURI)
|
|||
function isHostInMozHosts(aURI, aTyped, aPrefix)
|
||||
{
|
||||
let stmt = DBConn().createStatement(
|
||||
"SELECT host, typed, prefix "
|
||||
+ "FROM moz_hosts "
|
||||
+ "WHERE host = fixup_url(:host) "
|
||||
+ "AND frecency NOTNULL "
|
||||
`SELECT host, typed, prefix
|
||||
FROM moz_hosts
|
||||
WHERE host = fixup_url(:host)
|
||||
AND frecency NOTNULL`
|
||||
);
|
||||
let result = false;
|
||||
stmt.params.host = aURI.host;
|
||||
|
|
|
@ -52,10 +52,10 @@ function addPlace(aUrl, aFavicon) {
|
|||
|
||||
function addBookmark(aPlaceId, aType, aParent, aKeywordId, aFolderType, aTitle) {
|
||||
let stmt = mDBConn.createStatement(
|
||||
"INSERT INTO moz_bookmarks (fk, type, parent, keyword_id, folder_type, "
|
||||
+ "title, guid) "
|
||||
+ "VALUES (:place_id, :type, :parent, :keyword_id, :folder_type, :title, "
|
||||
+ "GENERATE_GUID())");
|
||||
`INSERT INTO moz_bookmarks (fk, type, parent, keyword_id, folder_type,
|
||||
title, guid)
|
||||
VALUES (:place_id, :type, :parent, :keyword_id, :folder_type, :title,
|
||||
GENERATE_GUID())`);
|
||||
stmt.params["place_id"] = aPlaceId || null;
|
||||
stmt.params["type"] = aType || bs.TYPE_BOOKMARK;
|
||||
stmt.params["parent"] = aParent || bs.unfiledBookmarksFolder;
|
||||
|
@ -92,10 +92,10 @@ tests.push({
|
|||
stmt.execute();
|
||||
stmt.finalize();
|
||||
stmt = mDBConn.createStatement(
|
||||
"INSERT INTO moz_annos (place_id, anno_attribute_id) "
|
||||
+ "VALUES (:place_id, "
|
||||
+ "(SELECT id FROM moz_anno_attributes WHERE name = :anno)"
|
||||
+ ")"
|
||||
`INSERT INTO moz_annos (place_id, anno_attribute_id)
|
||||
VALUES (:place_id,
|
||||
(SELECT id FROM moz_anno_attributes WHERE name = :anno)
|
||||
)`
|
||||
);
|
||||
stmt.params['place_id'] = this._placeId;
|
||||
stmt.params['anno'] = this._obsoleteWeaveAttribute;
|
||||
|
@ -131,8 +131,8 @@ tests.push({
|
|||
this._bookmarkId = addBookmark(this._placeId);
|
||||
// Add an obsolete attribute.
|
||||
let stmt = mDBConn.createStatement(
|
||||
"INSERT INTO moz_anno_attributes (name) "
|
||||
+ "VALUES (:anno1), (:anno2), (:anno3)"
|
||||
`INSERT INTO moz_anno_attributes (name)
|
||||
VALUES (:anno1), (:anno2), (:anno3)`
|
||||
);
|
||||
stmt.params['anno1'] = this._obsoleteSyncAttribute;
|
||||
stmt.params['anno2'] = this._obsoleteGuidAttribute;
|
||||
|
@ -140,10 +140,10 @@ tests.push({
|
|||
stmt.execute();
|
||||
stmt.finalize();
|
||||
stmt = mDBConn.createStatement(
|
||||
"INSERT INTO moz_items_annos (item_id, anno_attribute_id) "
|
||||
+ "SELECT :item_id, id "
|
||||
+ "FROM moz_anno_attributes "
|
||||
+ "WHERE name IN (:anno1, :anno2, :anno3)"
|
||||
`INSERT INTO moz_items_annos (item_id, anno_attribute_id)
|
||||
SELECT :item_id, id
|
||||
FROM moz_anno_attributes
|
||||
WHERE name IN (:anno1, :anno2, :anno3)`
|
||||
);
|
||||
stmt.params['item_id'] = this._bookmarkId;
|
||||
stmt.params['anno1'] = this._obsoleteSyncAttribute;
|
||||
|
@ -156,8 +156,8 @@ tests.push({
|
|||
check: function() {
|
||||
// Check that the obsolete annotations have been removed.
|
||||
let stmt = mDBConn.createStatement(
|
||||
"SELECT id FROM moz_anno_attributes "
|
||||
+ "WHERE name IN (:anno1, :anno2, :anno3)"
|
||||
`SELECT id FROM moz_anno_attributes
|
||||
WHERE name IN (:anno1, :anno2, :anno3)`
|
||||
);
|
||||
stmt.params['anno1'] = this._obsoleteSyncAttribute;
|
||||
stmt.params['anno2'] = this._obsoleteGuidAttribute;
|
||||
|
@ -723,11 +723,11 @@ tests.push({
|
|||
|
||||
function randomize_positions(aParent, aResultArray) {
|
||||
let stmt = mDBConn.createStatement(
|
||||
"UPDATE moz_bookmarks SET position = :rand " +
|
||||
"WHERE id IN ( " +
|
||||
"SELECT id FROM moz_bookmarks WHERE parent = :parent " +
|
||||
"ORDER BY RANDOM() LIMIT 1 " +
|
||||
") "
|
||||
`UPDATE moz_bookmarks SET position = :rand
|
||||
WHERE id IN (
|
||||
SELECT id FROM moz_bookmarks WHERE parent = :parent
|
||||
ORDER BY RANDOM() LIMIT 1
|
||||
)`
|
||||
);
|
||||
for (let i = 0; i < (NUM_BOOKMARKS / 2); i++) {
|
||||
stmt.params["parent"] = aParent;
|
||||
|
@ -739,9 +739,9 @@ tests.push({
|
|||
|
||||
// Build the expected ordered list of bookmarks.
|
||||
stmt = mDBConn.createStatement(
|
||||
"SELECT id, position " +
|
||||
"FROM moz_bookmarks WHERE parent = :parent " +
|
||||
"ORDER BY position ASC, ROWID ASC "
|
||||
`SELECT id, position
|
||||
FROM moz_bookmarks WHERE parent = :parent
|
||||
ORDER BY position ASC, ROWID ASC`
|
||||
);
|
||||
stmt.params["parent"] = aParent;
|
||||
while (stmt.executeStep()) {
|
||||
|
@ -762,8 +762,8 @@ tests.push({
|
|||
function check_order(aParent, aResultArray) {
|
||||
// Build the expected ordered list of bookmarks.
|
||||
let stmt = mDBConn.createStatement(
|
||||
"SELECT id, position FROM moz_bookmarks WHERE parent = :parent " +
|
||||
"ORDER BY position ASC"
|
||||
`SELECT id, position FROM moz_bookmarks WHERE parent = :parent
|
||||
ORDER BY position ASC`
|
||||
);
|
||||
stmt.params["parent"] = aParent;
|
||||
let pass = true;
|
||||
|
@ -1189,13 +1189,13 @@ tests.push({
|
|||
|
||||
check: function() {
|
||||
let stmt = mDBConn.createStatement(
|
||||
"SELECT h.id FROM moz_places h " +
|
||||
"JOIN moz_historyvisits v ON v.place_id = h.id AND visit_type NOT IN (0,4,7,8) " +
|
||||
"GROUP BY h.id HAVING h.visit_count <> count(*) " +
|
||||
"UNION ALL " +
|
||||
"SELECT h.id FROM moz_places h " +
|
||||
"JOIN moz_historyvisits v ON v.place_id = h.id " +
|
||||
"GROUP BY h.id HAVING h.last_visit_date <> MAX(v.visit_date) "
|
||||
`SELECT h.id FROM moz_places h
|
||||
JOIN moz_historyvisits v ON v.place_id = h.id AND visit_type NOT IN (0,4,7,8)
|
||||
GROUP BY h.id HAVING h.visit_count <> count(*)
|
||||
UNION ALL
|
||||
SELECT h.id FROM moz_places h
|
||||
JOIN moz_historyvisits v ON v.place_id = h.id
|
||||
GROUP BY h.id HAVING h.last_visit_date <> MAX(v.visit_date)`
|
||||
);
|
||||
do_check_false(stmt.executeStep());
|
||||
stmt.finalize();
|
||||
|
|
Загрузка…
Ссылка в новой задаче