Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Expression builder argument error by reverting #5506 #16255

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,6 @@ class Host < ApplicationRecord
end
end

def self.include_descendant_classes_in_expressions?
true
end

def self.non_clustered
where(:ems_cluster_id => nil)
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ def self.base_model
Vm
end

def self.include_descendant_classes_in_expressions?
true
end

def self.corresponding_model
if self == Vm
MiqTemplate
Expand Down
1 change: 1 addition & 0 deletions config/miq_expression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
- storage_files
- switches
- tenant_quotas
- tenants
- users
- vms
- volumes
Expand Down
7 changes: 1 addition & 6 deletions lib/miq_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -949,12 +949,7 @@ def self.build_relats(model, parent = {}, seen = [])
result = {:columns => model.attribute_names, :parent => parent}
result[:reflections] = {}

refs = model.reflections_with_virtual
if model.try(:include_descendant_classes_in_expressions?)
model.descendants.each { |desc| refs.reverse_merge!(desc.reflections_with_virtual) }
end

refs.each do |assoc, ref|
model.reflections_with_virtual.each do |assoc, ref|
next unless INCLUDE_TABLES.include?(assoc.to_s.pluralize)
next if assoc.to_s.pluralize == "event_logs" && parent[:root] == "Host" && !proto?
next if assoc.to_s.pluralize == "processes" && parent[:root] == "Host" # Process data not available yet for Host
Expand Down
17 changes: 0 additions & 17 deletions spec/lib/miq_expression_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2085,23 +2085,6 @@
end
end

context ".build_relats" do
it "includes reflections from descendant classes of Vm" do
relats = MiqExpression.get_relats(Vm)
expect(relats[:reflections][:cloud_tenant]).not_to be_blank
end

it "includes reflections from descendant classes of Host" do
relats = MiqExpression.get_relats(Host)
expect(relats[:reflections][:cloud_networks]).not_to be_blank
end

it "excludes reflections from descendant classes of VmOrTemplate " do
relats = MiqExpression.get_relats(VmOrTemplate)
expect(relats[:reflections][:cloud_tenant]).to be_blank
end
end

describe "#to_human" do
it "generates a human readable string for a 'FIELD' expression" do
exp = MiqExpression.new(">" => {"field" => "Vm-allocated_disk_storage", "value" => "5.megabytes"})
Expand Down