Commit 75ac1f73 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu Committed by Douglas Barbosa Alexandre

Fix delete_all on association

Previously, having the `where` turned this into a relation
so `ActiveRecord::Relation#delete_all` is called.

In Rails 6, `ActiveRecord::Associations::CollectionProxy#delete_all`
is called causing an error in the query.
parent 0d28fa86
......@@ -12,7 +12,7 @@ module Projects
matching_programming_languages = ensure_programming_languages(detection)
RepositoryLanguage.transaction do
project.repository_languages.where(programming_language_id: detection.deletions).delete_all
RepositoryLanguage.where(project_id: project.id, programming_language_id: detection.deletions).delete_all
detection.updates.each do |update|
RepositoryLanguage
......
......@@ -302,7 +302,11 @@ describe MergeRequest do
it 'returns empty requests' do
latest_merge_request_diff = merge_request.merge_request_diffs.create
latest_merge_request_diff.merge_request_diff_commits.where(sha: 'b83d6e391c22777fca1ed3012fce84f633d7fed0').delete_all
MergeRequestDiffCommit.where(
merge_request_diff_id: latest_merge_request_diff,
sha: 'b83d6e391c22777fca1ed3012fce84f633d7fed0'
).delete_all
expect(by_commit_sha).to be_empty
end
......
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