@@ -325,51 +325,51 class Query < ActiveRecord::Base | |||||
325 | sql = '' |
|
325 | sql = '' | |
326 | case operator_for field |
|
326 | case operator_for field | |
327 | when "=" |
|
327 | when "=" | |
328 |
|
|
328 | sql = "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" | |
329 | when "!" |
|
329 | when "!" | |
330 |
|
|
330 | sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))" | |
331 | when "!*" |
|
331 | when "!*" | |
332 | sql = "#{db_table}.#{db_field} IS NULL" |
|
332 | sql = "#{db_table}.#{db_field} IS NULL" | |
333 | sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter |
|
333 | sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter | |
334 | return sql |
|
|||
335 | when "*" |
|
334 | when "*" | |
336 | sql = "#{db_table}.#{db_field} IS NOT NULL" |
|
335 | sql = "#{db_table}.#{db_field} IS NOT NULL" | |
337 | sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter |
|
336 | sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter | |
338 | return sql |
|
|||
339 | when ">=" |
|
337 | when ">=" | |
340 |
|
|
338 | sql = "#{db_table}.#{db_field} >= #{v.first.to_i}" | |
341 | when "<=" |
|
339 | when "<=" | |
342 |
|
|
340 | sql = "#{db_table}.#{db_field} <= #{v.first.to_i}" | |
343 | when "o" |
|
341 | when "o" | |
344 |
|
|
342 | sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_false}" if field == "status_id" | |
345 | when "c" |
|
343 | when "c" | |
346 |
|
|
344 | sql = "#{IssueStatus.table_name}.is_closed=#{connection.quoted_true}" if field == "status_id" | |
347 | when ">t-" |
|
345 | when ">t-" | |
348 |
|
|
346 | sql = date_range_clause(db_table, db_field, - v.first.to_i, 0) | |
349 | when "<t-" |
|
347 | when "<t-" | |
350 |
|
|
348 | sql = date_range_clause(db_table, db_field, nil, - v.first.to_i) | |
351 | when "t-" |
|
349 | when "t-" | |
352 |
|
|
350 | sql = date_range_clause(db_table, db_field, - v.first.to_i, - v.first.to_i) | |
353 | when ">t+" |
|
351 | when ">t+" | |
354 |
|
|
352 | sql = date_range_clause(db_table, db_field, v.first.to_i, nil) | |
355 | when "<t+" |
|
353 | when "<t+" | |
356 |
|
|
354 | sql = date_range_clause(db_table, db_field, 0, v.first.to_i) | |
357 | when "t+" |
|
355 | when "t+" | |
358 |
|
|
356 | sql = date_range_clause(db_table, db_field, v.first.to_i, v.first.to_i) | |
359 | when "t" |
|
357 | when "t" | |
360 |
|
|
358 | sql = date_range_clause(db_table, db_field, 0, 0) | |
361 | when "w" |
|
359 | when "w" | |
362 | from = l(:general_first_day_of_week) == '7' ? |
|
360 | from = l(:general_first_day_of_week) == '7' ? | |
363 | # week starts on sunday |
|
361 | # week starts on sunday | |
364 | ((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) : |
|
362 | ((Date.today.cwday == 7) ? Time.now.at_beginning_of_day : Time.now.at_beginning_of_week - 1.day) : | |
365 | # week starts on monday (Rails default) |
|
363 | # week starts on monday (Rails default) | |
366 | Time.now.at_beginning_of_week |
|
364 | Time.now.at_beginning_of_week | |
367 |
|
|
365 | sql = "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(from), connection.quoted_date(from + 7.days)] | |
368 | when "~" |
|
366 | when "~" | |
369 |
|
|
367 | sql = "#{db_table}.#{db_field} LIKE '%#{connection.quote_string(v.first)}%'" | |
370 | when "!~" |
|
368 | when "!~" | |
371 |
|
|
369 | sql = "#{db_table}.#{db_field} NOT LIKE '%#{connection.quote_string(v.first)}%'" | |
372 | end |
|
370 | end | |
|
371 | ||||
|
372 | return sql | |||
373 | end |
|
373 | end | |
374 |
|
374 | |||
375 | def add_custom_fields_filters(custom_fields) |
|
375 | def add_custom_fields_filters(custom_fields) |
General Comments 0
You need to be logged in to leave comments.
Login now