]> source.dussan.org Git - redmine.git/commitdiff
Removes hardcoded table names in Repository#clear_changesets.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 8 May 2009 08:05:45 +0000 (08:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 8 May 2009 08:05:45 +0000 (08:05 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2715 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/repository.rb

index a205af5b4fe2dfb734c4fb859162e26409743740..bf181bfadc418306de8df2a0f4af6b00cdb3062e 100644 (file)
@@ -173,8 +173,9 @@ class Repository < ActiveRecord::Base
   end
   
   def clear_changesets
-    connection.delete("DELETE FROM changes WHERE changes.changeset_id IN (SELECT changesets.id FROM changesets WHERE changesets.repository_id = #{id})")
-    connection.delete("DELETE FROM changesets_issues WHERE changesets_issues.changeset_id IN (SELECT changesets.id FROM changesets WHERE changesets.repository_id = #{id})")
-    connection.delete("DELETE FROM changesets WHERE changesets.repository_id = #{id}")
+    cs, ch, ci = Changeset.table_name, Change.table_name, "#{table_name_prefix}changesets_issues#{table_name_suffix}"
+    connection.delete("DELETE FROM #{ch} WHERE #{ch}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
+    connection.delete("DELETE FROM #{ci} WHERE #{ci}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
+    connection.delete("DELETE FROM #{cs} WHERE #{cs}.repository_id = #{id}")
   end
 end