Commit 0e747c63 authored by Milan Crha's avatar Milan Crha

I#61 - Cannot search contacts for existence of boolean fields

Closes GNOME/evolution-data-server#61
parent 5f1d2650
......@@ -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);
}
}
......
......@@ -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,
......
......@@ -2,4 +2,5 @@ BEGIN:VCARD
UID:simple-1
FN:Foo Bar
EMAIL;INTERNET:foo.bar@example.org
X-MOZILLA-HTML:TRUE
END:VCARD
......@@ -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);
......
......@@ -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);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment