From: Simon Brandhof Date: Fri, 19 Oct 2012 13:04:44 +0000 (+0200) Subject: SONAR-3876 fail to rename a profile containing quotes on postgresql X-Git-Tag: 3.3~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=57cd995070325b9efef7956b5d2c568d4b663b92;p=sonarqube.git SONAR-3876 fail to rename a profile containing quotes on postgresql --- diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb index ca469daa5e0..a9eb887503f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb @@ -169,9 +169,12 @@ class Profile < ActiveRecord::Base child.parent_name=new_name child.save end - # PROPERTIES.TEXT_VALUE is CLOB but not VARCHAR. The operator '=' is supported by all the databases except Oracle. For this reason 'like' must be used. - # Repeat avec me : Oracle rocks. - Property.update_all({:text_value => new_name}, ['prop_key=? and text_value like ?', "sonar.profile.#{language}", old_name]) + Property.with_key("sonar.profile.#{language}").each do |prop| + if prop.text_value==old_name + prop.text_value=new_name + prop.save + end + end end end self diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb index 1189d89009f..0bd3305bdf9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb @@ -49,7 +49,7 @@ - <%= profile.active_rules.count -%> + <%= profile.count_active_rules -%> <%= profile.alerts.size -%>