fixed query error when first case is not contained 87/102487/1
authorJeesun Kim <iamjs.kim@samsung.com>
Tue, 6 Dec 2016 03:55:55 +0000 (12:55 +0900)
committerJeesun Kim <iamjs.kim@samsung.com>
Tue, 6 Dec 2016 03:57:56 +0000 (12:57 +0900)
Change-Id: If0aa7a8e95def2c679f34218ae0b3e11b915ce3f

server/db/ctsvc_db_query.c

index 40e84ce..88188a4 100644 (file)
@@ -2686,7 +2686,19 @@ static int __ctsvc_db_search_records_exec(const char *view_uri,
                                        temp_len = SAFE_SNPRINTF(&query, &query_size, len, " OR ");
                                        if (0 <= temp_len)
                                                len += temp_len;
+
+                               } else {
+                                       temp_len = SAFE_SNPRINTF(&query, &query_size, len, "SELECT * FROM ");
+                                       if (0 <= temp_len)
+                                               len += temp_len;
+                                       temp_len = SAFE_SNPRINTF(&query, &query_size, len, table);
+                                       if (0 <= temp_len)
+                                               len += temp_len;
+                                       temp_len = SAFE_SNPRINTF(&query, &query_size, len, " WHERE ");
+                                       if (0 <= temp_len)
+                                               len += temp_len;
                                }
+
                                snprintf(temp_query, sizeof(temp_query), "person_id IN (SELECT person_id "
                                                "FROM "CTS_TABLE_CONTACTS" WHERE deleted = 0 AND contact_id ");
                                temp_len = SAFE_SNPRINTF(&query, &query_size, len, temp_query);