Project

General

Profile

« Previous | Next » 

Revision ceeb3926

Added by Dominic Cleal over 6 years ago

Fixes #20955 - Remove conditions to {destroy, delete}_all calls

View differences:

app/services/fact_importer.rb
delete_query = FactValue.joins(:fact_name).where(:host => host, 'fact_names.type' => fact_name_class.name).where.not('fact_names.name' => facts.keys)
if ActiveRecord::Base.connection.adapter_name.downcase.starts_with? 'mysql'
# MySQL does not handle delete with inner query correctly (slow) so we will do two queries on purpose
payload[:count] = @counters[:deleted] = FactValue.delete_all(:id => delete_query.pluck(:id))
payload[:count] = @counters[:deleted] = FactValue.where(:id => delete_query.pluck(:id)).delete_all
else
# deletes all facts using a single SQL query with inner query otherwise
payload[:count] = @counters[:deleted] = delete_query.delete_all

Also available in: Unified diff