summaryrefslogtreecommitdiffstats
path: root/app/models/query.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-06-30 09:40:23 +0000
committerGo MAEDA <maeda@farend.jp>2023-06-30 09:40:23 +0000
commitbb3662894e3a16eaad0950dc83061343efbc5125 (patch)
tree5f5bf9d4ed9c00f3bf1574e203cf6338f7d7af49 /app/models/query.rb
parent66f16ff3485bcf6f65f57f971e086dbd6066b4a4 (diff)
downloadredmine-bb3662894e3a16eaad0950dc83061343efbc5125.tar.gz
redmine-bb3662894e3a16eaad0950dc83061343efbc5125.zip
"has been" and "has never been" filter operators can be very slow (#38527, #38788).
Patch by Go MAEDA. git-svn-id: https://svn.redmine.org/redmine/trunk@22271 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r--app/models/query.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index 117f6e226..c09932203 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -1458,11 +1458,13 @@ class Query < ActiveRecord::Base
" AND " +
queried_class.send(:sanitize_sql_for_conditions, ["#{JournalDetail.table_name}.old_value IN (?)", value.map(&:to_s)]) +
")"
- if %w[ev !ev].include?(operator)
- subquery <<
+ sql_ev =
+ if %w[ev !ev].include?(operator)
" OR " + queried_class.send(:sanitize_sql_for_conditions, ["#{db_table}.#{db_field} IN (?)", value.map(&:to_s)])
- end
- sql = "#{neg} EXISTS (#{subquery})"
+ else
+ ''
+ end
+ sql = "#{neg} (EXISTS (#{subquery})#{sql_ev})"
else
sql = '1=0'
end