[geary/geary-0.6] Use IN rather than OR to avoid SQLite error w/ large queries
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/geary-0.6] Use IN rather than OR to avoid SQLite error w/ large queries
- Date: Wed, 16 Apr 2014 21:17:30 +0000 (UTC)
commit 424518320dc21706181c628ebe21592979918844
Author: Jim Nelson <jim yorba org>
Date: Tue Apr 15 12:09:53 2014 -0700
Use IN rather than OR to avoid SQLite error w/ large queries
src/engine/imap-db/imap-db-folder.vala | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/src/engine/imap-db/imap-db-folder.vala b/src/engine/imap-db/imap-db-folder.vala
index 44a0769..59e8370 100644
--- a/src/engine/imap-db/imap-db-folder.vala
+++ b/src/engine/imap-db/imap-db-folder.vala
@@ -715,14 +715,13 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
do_add_to_unread_count(cx, -unread_count, cancellable);
StringBuilder sql = new StringBuilder("""
- DELETE FROM MessageLocationTable WHERE (
+ DELETE FROM MessageLocationTable WHERE message_id IN (
""");
- bool first = true;
- foreach (LocationIdentifier location in locs) {
- if (!first)
- sql.append(" OR ");
- sql.append_printf(" message_id='%s' ", location.message_id.to_string());
- first = false;
+ Gee.Iterator<LocationIdentifier> iter = locs.iterator();
+ while (iter.next()) {
+ sql.append_printf("%s", iter.get().message_id.to_string());
+ if (iter.has_next())
+ sql.append(", ");
}
sql.append(") AND folder_id=?");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]