summaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-02-07 16:10:57 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-02-07 16:10:57 +0100
commit9354714ba90720b6bf74213e65e2766831f46292 (patch)
tree236063cd16b610579a717d4a34e4062bf3366e25 /sonar-server
parent5da7732516fb007169e9765fbcf765cfb92fe57d (diff)
downloadsonarqube-9354714ba90720b6bf74213e65e2766831f46292.tar.gz
sonarqube-9354714ba90720b6bf74213e65e2766831f46292.zip
Apply sonar custom patches to ruby on rails
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/config/environment.rb44
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.5/lib/action_view/helpers/number_helper.rb10
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/gems/gems/activerecord-2.3.5/lib/active_record/association_preload.rb14
3 files changed, 24 insertions, 44 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/config/environment.rb b/sonar-server/src/main/webapp/WEB-INF/config/environment.rb
index 63bfc2d3024..632d8516cf2 100644
--- a/sonar-server/src/main/webapp/WEB-INF/config/environment.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/config/environment.rb
@@ -209,44 +209,6 @@ module JdbcSpec
end
end
-module ActionView
- module Helpers
- module NumberHelper
-
- def number_with_precision(number, *args)
- options = args.extract_options!
- options.symbolize_keys!
-
- defaults = I18n.translate('number.format', :locale => options[:locale], :raise => true) rescue {}
-
- # SONAR : do not merge with 'number.precision.format'. It usually removes definitions of delimiter and separator.
- # It looks to be fixed in Rails 2.3.
- #precision_defaults = I18n.translate('number.precision.format''number.precision.format', :locale => options[:locale],
- #defaults = defaults.merge(precision_defaults)
-
- unless args.empty?
- ActiveSupport::Deprecation.warn('number_with_precision takes an option hash ' +
- 'instead of a separate precision argument.', caller)
- precision = args[0] || defaults[:precision]
- end
-
- precision ||= (options[:precision] || defaults[:precision])
- separator ||= (options[:separator] || defaults[:separator])
- delimiter ||= (options[:delimiter] || defaults[:delimiter])
-
- begin
- rounded_number = (Float(number) * (10 ** precision)).round.to_f / 10 ** precision
- number_with_delimiter("%01.#{precision}f" % rounded_number,
- :separator => separator,
- :delimiter => delimiter)
- rescue
- number
- end
- end
- end
- end
-end
-
# patch for SONAR-1182. GWT does not support ISO8601 dates that end with 'Z'
# http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/i18n/client/DateTimeFormat.html
module ActiveSupport
@@ -258,9 +220,11 @@ module ActiveSupport
end
end
+#
# other patches :
-# - activerecord 2.2.2: fix Oracle bug when more than 1000 elements in IN clause. See lib/active_record/association_preload.rb
-# See https://rails.lighthouseapp.com/projects/8994/tickets/1533-preloading-more-than-1000-associated-records-causes-activerecordstatementinvalid-when-using-oracle
+# - activerecord : fix Oracle bug when more than 1000 elements in IN clause. See lib/active_record/association_preload.rb
+# See https://rails.lighthouseapp.com/projects/8994/tickets/1533-preloading-more-than-1000-associated-records-causes-activerecordstatementinvalid-when-using-oracle
+# - actionview NumberHelper, patch for number_with_precision()
require File.dirname(__FILE__) + '/../lib/sonar_webservice_plugins.rb'
require File.dirname(__FILE__) + '/../lib/database_version.rb'
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.5/lib/action_view/helpers/number_helper.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.5/lib/action_view/helpers/number_helper.rb
index 1760a13a9e6..b159887737e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.5/lib/action_view/helpers/number_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.5/lib/action_view/helpers/number_helper.rb
@@ -198,9 +198,13 @@ module ActionView
options.symbolize_keys!
defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
- precision_defaults = I18n.translate(:'number.precision.format', :locale => options[:locale],
- :raise => true) rescue {}
- defaults = defaults.merge(precision_defaults)
+
+ #SONAR do not merge with 'number.precision.format'. It usually removes definitions of delimiter and separator.
+ # The 2 following statements must be commented:
+ #precision_defaults = I18n.translate(:'number.precision.format', :locale => options[:locale],
+ # :raise => true) rescue {}
+ #defaults = defaults.merge(precision_defaults)
+ #SONAR
unless args.empty?
ActiveSupport::Deprecation.warn('number_with_precision takes an option hash ' +
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/activerecord-2.3.5/lib/active_record/association_preload.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/activerecord-2.3.5/lib/active_record/association_preload.rb
index e4ab69aa1b7..1a596b21d75 100644
--- a/sonar-server/src/main/webapp/WEB-INF/gems/gems/activerecord-2.3.5/lib/active_record/association_preload.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/gems/gems/activerecord-2.3.5/lib/active_record/association_preload.rb
@@ -333,14 +333,22 @@ module ActiveRecord
end
end
conditions = "#{table_name}.#{connection.quote_column_name(primary_key)} #{in_or_equals_for_ids(ids)}"
+
+ #SONAR
+ conditions = ([conditions] * (ids.size.to_f/1000).ceil).join(" OR ")
+ #SONAR
+
conditions << append_conditions(reflection, preload_options)
+
+ #SONAR
associated_records = klass.with_exclusive_scope do
- klass.find(:all, :conditions => [conditions, ids],
+ klass.find(:all, :conditions => [conditions, *ids.in_groups_of(1000, false)],
:include => options[:include],
:select => options[:select],
:joins => options[:joins],
:order => options[:order])
end
+ #SONAR
set_association_single_records(id_map, reflection.name, associated_records, primary_key)
end
end
@@ -356,6 +364,10 @@ module ActiveRecord
conditions = "#{reflection.klass.quoted_table_name}.#{foreign_key} #{in_or_equals_for_ids(ids)}"
end
+ #SONAR patch for Oracle IN clause with more than 1000 elements
+ conditions = ([conditions] * (ids.size.to_f/1000).ceil).join(" OR ")
+ #SONAR
+
conditions << append_conditions(reflection, preload_options)
reflection.klass.with_exclusive_scope do