282 |
282 |
"t-" => :label_ago,
|
283 |
283 |
"~" => :label_contains,
|
284 |
284 |
"!~" => :label_not_contains,
|
|
285 |
"^" => :label_starts_with,
|
|
286 |
"$" => :label_ends_with,
|
285 |
287 |
"=p" => :label_any_issues_in_project,
|
286 |
288 |
"=!p" => :label_any_issues_not_in_project,
|
287 |
289 |
"!p" => :label_no_issues_in_project,
|
... | ... | |
297 |
299 |
:list_subprojects => [ "*", "!*", "=", "!" ],
|
298 |
300 |
:date => [ "=", ">=", "<=", "><", "<t+", ">t+", "><t+", "t+", "nd", "t", "ld", "nw", "w", "lw", "l2w", "nm", "m", "lm", "y", ">t-", "<t-", "><t-", "t-", "!*", "*" ],
|
299 |
301 |
:date_past => [ "=", ">=", "<=", "><", ">t-", "<t-", "><t-", "t-", "t", "ld", "w", "lw", "l2w", "m", "lm", "y", "!*", "*" ],
|
300 |
|
:string => [ "~", "=", "!~", "!", "!*", "*" ],
|
301 |
|
:text => [ "~", "!~", "!*", "*" ],
|
|
302 |
:string => [ "~", "=", "!~", "!", "^", "$", "!*", "*" ],
|
|
303 |
:text => [ "~", "!~", "^", "$", "!*", "*" ],
|
302 |
304 |
:integer => [ "=", ">=", "<=", "><", "!*", "*" ],
|
303 |
305 |
:float => [ "=", ">=", "<=", "><", "!*", "*" ],
|
304 |
306 |
:relation => ["=", "=p", "=!p", "!p", "*o", "!o", "!*", "*"],
|
... | ... | |
1260 |
1262 |
when "~"
|
1261 |
1263 |
sql = sql_contains("#{db_table}.#{db_field}", value.first)
|
1262 |
1264 |
when "!~"
|
1263 |
|
sql = sql_contains("#{db_table}.#{db_field}", value.first, false)
|
|
1265 |
sql = sql_contains("#{db_table}.#{db_field}", value.first, :match => false)
|
|
1266 |
when "^"
|
|
1267 |
sql = sql_contains("#{db_table}.#{db_field}", value.first, :starts_with => true)
|
|
1268 |
when "$"
|
|
1269 |
sql = sql_contains("#{db_table}.#{db_field}", value.first, :ends_with => true)
|
1264 |
1270 |
else
|
1265 |
1271 |
raise "Unknown query operator #{operator}"
|
1266 |
1272 |
end
|
... | ... | |
1269 |
1275 |
end
|
1270 |
1276 |
|
1271 |
1277 |
# Returns a SQL LIKE statement with wildcards
|
1272 |
|
def sql_contains(db_field, value, match=true)
|
|
1278 |
def sql_contains(db_field, value, options={})
|
|
1279 |
options = {} unless options.is_a?(Hash)
|
|
1280 |
options.symbolize_keys!
|
|
1281 |
prefix = suffix = nil
|
|
1282 |
prefix = '%' if options[:ends_with]
|
|
1283 |
suffix = '%' if options[:starts_with]
|
|
1284 |
prefix = suffix = '%' if prefix.nil? && suffix.nil?
|
1273 |
1285 |
queried_class.send :sanitize_sql_for_conditions,
|
1274 |
|
[Redmine::Database.like(db_field, '?', :match => match), "%#{value}%"]
|
|
1286 |
[Redmine::Database.like(db_field, '?', :match => options[:match]), "#{prefix}#{value}#{suffix}"]
|
1275 |
1287 |
end
|
1276 |
1288 |
|
1277 |
1289 |
# Adds a filter for the given custom field
|