-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
Looks like only() overwrites without() fields and vice versa.
I found this when I tried to do an indexOnly query, but couldn't get it to work due to the _type being added:
Friendship.only(:name).where(name: 'Hello').first MONGODB (2ms) test_development['friendships'].find({:name=>"Hello"}, {:_type=>1, :name=>1}).limit(-1).sort([[:_id, :asc]])
so I chained the following without, but now the name is gone from the fields returned:
{{`}}ruby
Friendship.only(:name).without(:_type).where(name: 'Hello').first
MONGODB (24ms) test_development['friendships'].find({:name=>"Hello"}, {:_type=>0}).limit(-1).sort([[:_id, :asc]])
``