From: Marc Olivier Chouinard Date: Tue, 14 Oct 2014 13:53:12 +0000 (-0400) Subject: FS-6910 #resolve Multiple entry with the same first, last name or extension in the... X-Git-Tag: v1.4.13~1^2~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ca349a3f814cb78bcb7f0ebbbf02f067b927d18;p=thirdparty%2Ffreeswitch.git 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. --- 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);