File: 1004_ContactWriter-prevent-aggregation-within-the-same-co.patch

package info (click to toggle)
qtcontacts-sqlite 0.3.20-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,952 kB
  • sloc: cpp: 32,880; ansic: 1,269; xml: 62; makefile: 32; sh: 18
file content (28 lines) | stat: -rw-r--r-- 1,406 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Author: Alberto Mardegan <mardy@users.sourceforge.net>
Description: ContactWriter: prevent aggregation within the same collection
 .
 We assume that contacts within a collection are all different.
 .
 Fixes: https://gitlab.com/ubports/development/core/qtcontacts-sqlite/-/issues/2

--- a/src/engine/contactwriter.cpp
+++ b/src/engine/contactwriter.cpp
@@ -4040,6 +4040,10 @@
             " SELECT secondId FROM Relationships WHERE firstId = :contactId AND type = 'IsNot'"
             " UNION"
             " SELECT firstId FROM Relationships WHERE secondId = :contactId AND type = 'IsNot'"
+            " UNION"
+            " SELECT firstId FROM Relationships WHERE secondId IN ("
+                " SELECT contactId FROM Contacts WHERE collectionId = :collectionId"
+            " ) AND type = 'Aggregates'"
         " )"));
 
     // Use a simple match algorithm, looking for exact matches on name fields,
@@ -4053,6 +4057,7 @@
     QMap<QString, QVariant> bindings;
     bindings.insert(":lastName", lastName);
     bindings.insert(":contactId", ContactId::databaseId(*contact));
+    bindings.insert(":collectionId", ContactCollectionId::databaseId(contact->collectionId()));
     bindings.insert(":excludeGender", excludeGender);
     if (!m_database.createTemporaryContactIdsTable(possibleAggregatesTable,
                                                    QString(), where, orderBy, bindings)) {