GitLab steht Mittwoch, den 23. September, zwischen 10:00 und 12:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

Commit dd090885 authored by jplang's avatar jplang

Don't pass conditions to #delete_all.

git-svn-id: https://svn.redmine.org/redmine/trunk@15675 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent b10f775a
......@@ -169,8 +169,8 @@ class ApplicationController < ActionController::Base
def logout_user
if User.current.logged?
cookies.delete(autologin_cookie_name)
Token.delete_all(["user_id = ? AND action = ?", User.current.id, 'autologin'])
Token.delete_all(["user_id = ? AND action = ? AND value = ?", User.current.id, 'session', session[:tk]])
Token.where(["user_id = ? AND action = ?", User.current.id, 'autologin']).delete_all
Token.where(["user_id = ? AND action = ? AND value = ?", User.current.id, 'session', session[:tk]]).delete_all
self.logged_user = nil
end
end
......
......@@ -108,6 +108,6 @@ class IssueStatus < ActiveRecord::Base
# Deletes associated workflows
def delete_workflow_rules
WorkflowRule.delete_all(["old_status_id = :id OR new_status_id = :id", {:id => id}])
WorkflowRule.where(["old_status_id = :id OR new_status_id = :id", {:id => id}]).delete_all
end
end
......@@ -508,7 +508,7 @@ class Project < ActiveRecord::Base
def delete_all_members
me, mr = Member.table_name, MemberRole.table_name
self.class.connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.project_id = #{id})")
Member.delete_all(['project_id = ?', id])
Member.where(:project_id => id).delete_all
end
# Return a Principal scope of users/groups issues can be assigned to
......
......@@ -10,6 +10,6 @@ class SetTopicAuthorsAsWatchers < ActiveRecord::Migration
def self.down
# Removes all message watchers
Watcher.delete_all("watchable_type = 'Message'")
Watcher.where("watchable_type = 'Message'").delete_all
end
end
......@@ -7,6 +7,6 @@ class EnableCalendarAndGanttModulesWhereAppropriate < ActiveRecord::Migration
end
def self.down
EnabledModule.delete_all("name = 'calendar' OR name = 'gantt'")
EnabledModule.where("name = 'calendar' OR name = 'gantt'").delete_all
end
end
class AddUniqueIndexOnMembers < ActiveRecord::Migration
def self.up
# Clean and reassign MemberRole rows if needed
MemberRole.delete_all("member_id NOT IN (SELECT id FROM #{Member.table_name})")
MemberRole.where("member_id NOT IN (SELECT id FROM #{Member.table_name})").delete_all
MemberRole.update_all("member_id =" +
" (SELECT min(m2.id) FROM #{Member.table_name} m1, #{Member.table_name} m2" +
" WHERE m1.user_id = m2.user_id AND m1.project_id = m2.project_id" +
......@@ -9,7 +9,7 @@ class AddUniqueIndexOnMembers < ActiveRecord::Migration
# Remove duplicates
Member.connection.select_values("SELECT m.id FROM #{Member.table_name} m" +
" WHERE m.id > (SELECT min(m1.id) FROM #{Member.table_name} m1 WHERE m1.user_id = m.user_id AND m1.project_id = m.project_id)").each do |i|
Member.delete_all(["id = ?", i])
Member.where(["id = ?", i]).delete_all
end
# Then add a unique index
......
......@@ -4,7 +4,7 @@ class AddUniqueIndexToIssueRelations < ActiveRecord::Migration
# Remove duplicates
IssueRelation.connection.select_values("SELECT r.id FROM #{IssueRelation.table_name} r" +
" WHERE r.id > (SELECT min(r1.id) FROM #{IssueRelation.table_name} r1 WHERE r1.issue_from_id = r.issue_from_id AND r1.issue_to_id = r.issue_to_id)").each do |i|
IssueRelation.delete_all(["id = ?", i])
IssueRelation.where(["id = ?", i]).delete_all
end
add_index :issue_relations, [:issue_from_id, :issue_to_id], :unique => true
......
......@@ -237,7 +237,7 @@ task :migrate_from_mantis => :environment do
# Users
print "Migrating users"
User.delete_all "login <> 'admin'"
User.where("login <> 'admin'").delete_all
users_map = {}
users_migrated = 0
MantisUser.all.each do |user|
......
......@@ -160,7 +160,7 @@ class AdminControllerTest < Redmine::ControllerTest
private
def delete_configuration_data
Role.delete_all('builtin = 0')
Role.where('builtin = 0').delete_all
Tracker.delete_all
IssueStatus.delete_all
Enumeration.delete_all
......
......@@ -71,7 +71,7 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def test_index_should_not_list_issues_when_module_disabled
EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
EnabledModule.where("name = 'issue_tracking' AND project_id = 1").delete_all
get :index
assert_response :success
assert_template 'index'
......@@ -1231,7 +1231,7 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_show_should_display_update_form_with_minimal_permissions
Role.find(1).update_attribute :permissions, [:view_issues, :add_issue_notes]
WorkflowTransition.delete_all :role_id => 1
WorkflowTransition.where(:role_id => 1).delete_all
@request.session[:user_id] = 2
get :show, :id => 1
......@@ -1796,7 +1796,7 @@ class IssuesControllerTest < Redmine::ControllerTest
def test_get_new_with_minimal_permissions
Role.find(1).update_attribute :permissions, [:add_issues]
WorkflowTransition.delete_all :role_id => 1
WorkflowTransition.where(:role_id => 1).delete_all
@request.session[:user_id] = 2
get :new, :project_id => 1, :tracker_id => 1
......@@ -2833,7 +2833,7 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def setup_without_workflow_privilege
WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
WorkflowTransition.where(["role_id = ?", Role.anonymous.id]).delete_all
Role.anonymous.add_permission! :add_issues, :add_issue_notes
end
private :setup_without_workflow_privilege
......@@ -2900,7 +2900,7 @@ class IssuesControllerTest < Redmine::ControllerTest
end
def setup_with_workflow_privilege
WorkflowTransition.delete_all(["role_id = ?", Role.anonymous.id])
WorkflowTransition.where(["role_id = ?", Role.anonymous.id]).delete_all
WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1,
:old_status_id => 1, :new_status_id => 3)
WorkflowTransition.create!(:role => Role.anonymous, :tracker_id => 1,
......@@ -4531,7 +4531,7 @@ class IssuesControllerTest < Redmine::ControllerTest
# Fixes random test failure with Mysql
# where Issue.where(:project_id => 2).limit(2).order('id desc')
# doesn't return the expected results
Issue.delete_all("project_id=2")
Issue.where("project_id=2").delete_all
@request.session[:user_id] = 2
assert_difference 'Issue.count', 2 do
......
......@@ -23,7 +23,7 @@ class DefaultDataTest < ActiveSupport::TestCase
def test_no_data
assert !Redmine::DefaultData::Loader::no_data?
Role.delete_all("builtin = 0")
Role.where("builtin = 0").delete_all
Tracker.delete_all
IssueStatus.delete_all
Enumeration.delete_all
......@@ -33,7 +33,7 @@ class DefaultDataTest < ActiveSupport::TestCase
def test_load
valid_languages.each do |lang|
begin
Role.delete_all("builtin = 0")
Role.where("builtin = 0").delete_all
Tracker.delete_all
IssueStatus.delete_all
Enumeration.delete_all
......
......@@ -46,7 +46,7 @@ class NewsTest < ActiveSupport::TestCase
end
def test_should_not_include_news_for_projects_with_news_disabled
EnabledModule.delete_all(["project_id = ? AND name = ?", 2, 'news'])
EnabledModule.where(["project_id = ? AND name = ?", 2, 'news']).delete_all
project = Project.find(2)
# Add a piece of news to the project
......
......@@ -1051,7 +1051,7 @@ class UserTest < ActiveSupport::TestCase
end
def test_own_account_deletable_should_be_false_for_a_single_admin
User.delete_all(["admin = ? AND id <> ?", true, 1])
User.where(["admin = ? AND id <> ?", true, 1]).delete_all
with_settings :unsubscribe => '1' do
assert_equal false, User.find(1).own_account_deletable?
......
......@@ -150,7 +150,7 @@ class WatcherTest < ActiveSupport::TestCase
end
def test_prune_with_user
Watcher.delete_all("user_id = 9")
Watcher.where("user_id = 9").delete_all
user = User.find(9)
# public
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment