Skip to content

Commit 4963ab9

Browse files
authored
MONGOID-5097 Test: any_of with multiple conditions and :exists in the first one on a Time field attempts to evolve true|false to Time (#5323)
1 parent 14f6f69 commit 4963ab9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

spec/mongoid/criteria/queryable/selectable_logical_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,5 +2093,27 @@
20932093
end
20942094
end
20952095
end
2096+
2097+
# This test confirms that MONGOID-5097 has been repaired.
2098+
context "when using exists on a field of type Time" do
2099+
let(:criteria) do
2100+
Dictionary.any_of({:published.exists => true}, published: nil)
2101+
end
2102+
2103+
it "doesn't raise an error" do
2104+
expect do
2105+
criteria
2106+
end.to_not raise_error
2107+
end
2108+
2109+
it "generates the correct selector" do
2110+
expect(criteria.selector).to eq({
2111+
"$or" => [ {
2112+
"published" => { "$exists" => true }
2113+
}, {
2114+
"published" => nil
2115+
} ] } )
2116+
end
2117+
end
20962118
end
20972119
end

0 commit comments

Comments
 (0)