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.4~463 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0fb0a76254e9aa12c7d1e3050c668aa81ac75a78;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 0a650cc9187..be5d8b4acbd 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 -%>