summaryrefslogtreecommitdiffstats
path: root/app/models/query.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-11-28 10:29:48 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-11-28 10:29:48 +0000
commit99b52c87967752b661662a8c85dd674042e13218 (patch)
tree0c5dbfc1079445c0b79bf20cb257790fdb5a8594 /app/models/query.rb
parent915bbcfaff8a5db56bc60b90fb690b7f4be3b555 (diff)
downloadredmine-99b52c87967752b661662a8c85dd674042e13218.tar.gz
redmine-99b52c87967752b661662a8c85dd674042e13218.zip
Rescue invalid query statement error with an error message.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3104 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r--app/models/query.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index d15f7c3c7..2e0ddc489 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -61,6 +61,9 @@ class QueryCustomFieldColumn < QueryColumn
end
class Query < ActiveRecord::Base
+ class StatementInvalid < ::ActiveRecord::StatementInvalid
+ end
+
belongs_to :project
belongs_to :user
serialize :filters
@@ -392,6 +395,8 @@ class Query < ActiveRecord::Base
# Returns the issue count
def issue_count
Issue.count(:include => [:status, :project], :conditions => statement)
+ rescue ::ActiveRecord::StatementInvalid => e
+ raise StatementInvalid.new(e.message)
end
# Returns the issue count by group or nil if query is not grouped
@@ -406,6 +411,8 @@ class Query < ActiveRecord::Base
else
nil
end
+ rescue ::ActiveRecord::StatementInvalid => e
+ raise StatementInvalid.new(e.message)
end
# Returns the issues
@@ -419,6 +426,8 @@ class Query < ActiveRecord::Base
:order => order_option,
:limit => options[:limit],
:offset => options[:offset]
+ rescue ::ActiveRecord::StatementInvalid => e
+ raise StatementInvalid.new(e.message)
end
# Returns the journals
@@ -429,6 +438,8 @@ class Query < ActiveRecord::Base
:order => options[:order],
:limit => options[:limit],
:offset => options[:offset]
+ rescue ::ActiveRecord::StatementInvalid => e
+ raise StatementInvalid.new(e.message)
end
# Returns the versions
@@ -436,6 +447,8 @@ class Query < ActiveRecord::Base
def versions(options={})
Version.find :all, :include => :project,
:conditions => Query.merge_conditions(project_statement, options[:conditions])
+ rescue ::ActiveRecord::StatementInvalid => e
+ raise StatementInvalid.new(e.message)
end
private