diff options
author | Etienne Massip <etienne.massip@gmail.com> | 2011-10-12 23:45:47 +0000 |
---|---|---|
committer | Etienne Massip <etienne.massip@gmail.com> | 2011-10-12 23:45:47 +0000 |
commit | a118c4ccb093306073d22cbbc69e5d4d4b066131 (patch) | |
tree | 9f9ec3ed7217473679fb8668ba2d9f96ae8d2536 /app/models/query.rb | |
parent | 765978871d6cf2d8f3e73fb7cc959460fec2d73b (diff) | |
download | redmine-a118c4ccb093306073d22cbbc69e5d4d4b066131.tar.gz redmine-a118c4ccb093306073d22cbbc69e5d4d4b066131.zip |
Fixed shot filter expression parsing depending upon field operators (#8371).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7624 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r-- | app/models/query.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/models/query.rb b/app/models/query.rb index c79677e2b..9eac4b81c 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -308,9 +308,12 @@ class Query < ActiveRecord::Base end def add_short_filter(field, expression) - return unless expression - parms = expression.scan(/^(o|c|!\*|!|\*)?(.*)$/).first - add_filter field, (parms[0] || "="), [parms[1] || ""] + return unless expression && available_filters.has_key?(field) + field_type = available_filters[field][:type] + @@operators_by_filter_type[field_type].sort.reverse.detect do |operator| + next unless expression =~ /^#{Regexp.escape(operator)}(.*)$/ + add_filter field, operator, $1.present? ? $1.split('|') : [''] + end || add_filter(field, '=', expression.split('|')) end # Add multiple filters using +add_filter+ |