[evolution-data-server] I#61 - Cannot search contacts for existence of boolean fields
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] I#61 - Cannot search contacts for existence of boolean fields
- Date: Tue, 4 Dec 2018 11:37:28 +0000 (UTC)
commit 0e747c63355710c6054e5254b46ef02af84831ad
Author: Milan Crha <mcrha redhat com>
Date: Tue Dec 4 12:36:53 2018 +0100
I#61 - Cannot search contacts for existence of boolean fields
Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/61
src/addressbook/libedata-book/e-book-cache.c | 7 ++++--
src/addressbook/libedata-book/e-book-sqlite.c | 7 ++++--
tests/libebook/data/vcards/simple-1.vcf | 1 +
tests/libedata-book/test-book-cache-get-contact.c | 23 +++++++++++++++++-
tests/libedata-book/test-sqlite-get-contact.c | 29 +++++++++++++++++++++--
5 files changed, 60 insertions(+), 7 deletions(-)
---
diff --git a/src/addressbook/libedata-book/e-book-cache.c b/src/addressbook/libedata-book/e-book-cache.c
index 45a8cad07..3f6e0ece5 100644
--- a/src/addressbook/libedata-book/e-book-cache.c
+++ b/src/addressbook/libedata-book/e-book-cache.c
@@ -2304,8 +2304,11 @@ query_preflight_check (PreflightContext *context,
* or fields which hold multiple strings
*/
if (test->field) {
- if (test->field->type != G_TYPE_STRING &&
- test->field->type != E_TYPE_CONTACT_ATTR_LIST) {
+ if (test->field->type == G_TYPE_BOOLEAN &&
+ field_test == BOOK_QUERY_EXISTS) {
+ context->status = MAX (context->status, PREFLIGHT_NOT_SUMMARIZED);
+ } else if (test->field->type != G_TYPE_STRING &&
+ test->field->type != E_TYPE_CONTACT_ATTR_LIST) {
context->status = MAX (context->status, PREFLIGHT_INVALID);
}
}
diff --git a/src/addressbook/libedata-book/e-book-sqlite.c b/src/addressbook/libedata-book/e-book-sqlite.c
index 06788cd77..991c5397e 100644
--- a/src/addressbook/libedata-book/e-book-sqlite.c
+++ b/src/addressbook/libedata-book/e-book-sqlite.c
@@ -4827,8 +4827,11 @@ query_preflight_check (PreflightContext *context,
* or fields which hold multiple strings
*/
if (test->field) {
- if (test->field->type != G_TYPE_STRING &&
- test->field->type != E_TYPE_CONTACT_ATTR_LIST) {
+ if (test->field->type == G_TYPE_BOOLEAN &&
+ field_test == BOOK_QUERY_EXISTS) {
+ context->status = MAX (context->status, PREFLIGHT_NOT_SUMMARIZED);
+ } else if (test->field->type != G_TYPE_STRING &&
+ test->field->type != E_TYPE_CONTACT_ATTR_LIST) {
context->status = MAX (context->status, PREFLIGHT_INVALID);
EBSQL_NOTE (
PREFLIGHT,
diff --git a/tests/libebook/data/vcards/simple-1.vcf b/tests/libebook/data/vcards/simple-1.vcf
index a42f151f2..32b3908c0 100644
--- a/tests/libebook/data/vcards/simple-1.vcf
+++ b/tests/libebook/data/vcards/simple-1.vcf
@@ -2,4 +2,5 @@ BEGIN:VCARD
UID:simple-1
FN:Foo Bar
EMAIL;INTERNET:foo bar example org
+X-MOZILLA-HTML:TRUE
END:VCARD
diff --git a/tests/libedata-book/test-book-cache-get-contact.c
b/tests/libedata-book/test-book-cache-get-contact.c
index 341e289b4..e9e810a1b 100644
--- a/tests/libedata-book/test-book-cache-get-contact.c
+++ b/tests/libedata-book/test-book-cache-get-contact.c
@@ -44,7 +44,26 @@ test_get_contact (TCUFixture *fixture,
g_object_unref (other);
}
+static void
+test_search_boolean (TCUFixture *fixture,
+ gconstpointer user_data)
+{
+ GSList *uids = NULL;
+ GError *error = NULL;
+
+ tcu_add_contact_from_test_case (fixture, "simple-1", NULL);
+
+ if (!e_book_cache_search_uids (fixture->book_cache, "(exists \"wants_html\")", &uids, NULL, &error))
+ g_error ("Failed to search for contact: %s", error->message);
+
+ g_assert_cmpint (g_slist_length (uids), ==, 1);
+
+ g_slist_free_full (uids, g_free);
+}
+
static TCUClosure closures[] = {
+ { NULL },
+ { tcu_setup_empty_book },
{ NULL },
{ tcu_setup_empty_book }
};
@@ -52,6 +71,8 @@ static TCUClosure closures[] = {
static const gchar *paths[] = {
"/EBookCache/DefaultSummary/GetContact",
"/EBookCache/EmptySummary/GetContact",
+ "/EBookCache/DefaultSummary/SearchBoolean",
+ "/EBookCache/EmptySummary/SearchBoolean"
};
gint
@@ -72,7 +93,7 @@ main (gint argc,
for (ii = 0; ii < G_N_ELEMENTS (closures); ii++) {
g_test_add (
paths[ii], TCUFixture, &closures[ii],
- tcu_fixture_setup, test_get_contact, tcu_fixture_teardown);
+ tcu_fixture_setup, ii < 2 ? test_get_contact : test_search_boolean,
tcu_fixture_teardown);
}
return e_test_server_utils_run_full (0);
diff --git a/tests/libedata-book/test-sqlite-get-contact.c b/tests/libedata-book/test-sqlite-get-contact.c
index afbc8c951..ab8e060d3 100644
--- a/tests/libedata-book/test-sqlite-get-contact.c
+++ b/tests/libedata-book/test-sqlite-get-contact.c
@@ -45,7 +45,28 @@ test_get_contact (EbSqlFixture *fixture,
g_object_unref (other);
}
+static void
+test_search_boolean (EbSqlFixture *fixture,
+ gconstpointer user_data)
+{
+ GSList *uids = NULL;
+ GError *error = NULL;
+
+ add_contact_from_test_case (fixture, "simple-1", NULL);
+
+ if (!e_book_sqlite_search_uids (fixture->ebsql, "(exists \"wants_html\")", &uids, NULL, &error))
+ g_error ("Failed to search for contact: %s", error->message);
+
+ g_assert_cmpint (g_slist_length (uids), ==, 1);
+
+ g_slist_free_full (uids, g_free);
+}
+
static EbSqlClosure closures[] = {
+ { FALSE, NULL },
+ { TRUE, NULL },
+ { FALSE, setup_empty_book },
+ { TRUE, setup_empty_book },
{ FALSE, NULL },
{ TRUE, NULL },
{ FALSE, setup_empty_book },
@@ -56,7 +77,11 @@ static const gchar *paths[] = {
"/EBookSqlite/DefaultSummary/StoreVCards/GetContact",
"/EBookSqlite/DefaultSummary/NoVCards/GetContact",
"/EBookSqlite/EmptySummary/StoreVCards/GetContact",
- "/EBookSqlite/EmptrySummary/NoVCards/GetContact"
+ "/EBookSqlite/EmptrySummary/NoVCards/GetContact",
+ "/EBookSqlite/DefaultSummary/StoreVCards/SearchBoolean",
+ "/EBookSqlite/DefaultSummary/NoVCards/SearchBoolean",
+ "/EBookSqlite/EmptySummary/StoreVCards/SearchBoolean",
+ "/EBookSqlite/EmptrySummary/NoVCards/SearchBoolean"
};
gint
@@ -77,7 +102,7 @@ main (gint argc,
for (i = 0; i < G_N_ELEMENTS (closures); i++)
g_test_add (
paths[i], EbSqlFixture, &closures[i],
- e_sqlite_fixture_setup, test_get_contact, e_sqlite_fixture_teardown);
+ e_sqlite_fixture_setup, i < 4 ? test_get_contact : test_search_boolean,
e_sqlite_fixture_teardown);
return e_test_server_utils_run_full (0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]