From 2ca349a3f814cb78bcb7f0ebbbf02f067b927d18 Mon Sep 17 00:00:00 2001 From: Marc Olivier Chouinard Date: Tue, 14 Oct 2014 09:53:12 -0400 Subject: [PATCH] FS-6910 #resolve Multiple entry with the same first, last name or extension in the directory would only return 1 entry. Fix issue where group by would produce multiple row of count(*) result. Using distinct instead wouldn't solve the issue in SQLITE because of a bug, so solution is to use a subselect. --- src/mod/applications/mod_directory/mod_directory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod/applications/mod_directory/mod_directory.c b/src/mod/applications/mod_directory/mod_directory.c index e37b89a660..b46bab89e3 100644 --- a/src/mod/applications/mod_directory/mod_directory.c +++ b/src/mod/applications/mod_directory/mod_directory.c @@ -873,7 +873,7 @@ switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *p globals.hostname, switch_core_session_get_uuid(session), (params->search_by == SEARCH_BY_LAST_NAME ? "last_name_digit" : "first_name_digit"), params->digits); } - sql = switch_mprintf("select count(*) from directory_search where %s group by last_name, first_name, extension", sql_where); + sql = switch_mprintf("select count(*) from (select distinct first_name, last_name, extension from directory_search where %s) AS dsearch", sql_where); directory_execute_sql_callback(globals.mutex, sql, sql2str_callback, &cbt); switch_safe_free(sql);