fix: Avoid joining tables to fix the distinct value query (#7965)
DISTINCT query with custom attributes return an error. To avoid the error, this PR refactors the query to include tags only when it is required. Fixes #7931 Fixes #7836 Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
@@ -35,7 +35,7 @@ class Contacts::FilterService < FilterService
|
||||
" (contacts.#{attribute_key})::#{current_filter['data_type']} #{filter_operator_value}#{current_filter['data_type']} #{query_operator} "
|
||||
when 'standard'
|
||||
if attribute_key == 'labels'
|
||||
" tags.id #{filter_operator_value} #{query_operator} "
|
||||
tag_filter_query('Contact', 'contacts', query_hash, current_index)
|
||||
else
|
||||
" LOWER(contacts.#{attribute_key}) #{filter_operator_value} #{query_operator} "
|
||||
end
|
||||
@@ -54,7 +54,7 @@ class Contacts::FilterService < FilterService
|
||||
end
|
||||
|
||||
def base_relation
|
||||
Current.account.contacts.distinct(:id).left_outer_joins(:labels)
|
||||
Current.account.contacts
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user