Skip to content

.only and .without #96

@JamesHarrison

Description

@JamesHarrison

In previous versions of origin, calling .without and .only resulted in a latest-takes-precedence behaviour (.without would strip .only, .only would strip .without). MongoDB cannot include and exclude fields at the same time (error 10053 "You cannot currently mix including and excluding fields. Contact us if this is an issue.", on 2.4.6).

In the current version the behaviour appears to be incompatible with MongoDB. Even the tests expect a result which according to MongoDB should not work, as I discovered when trying to fix this:

1) Origin::Optional#only when #without was called first adds both fields to option
 Failure/Error: expect(selection.options).to eq(

   expected: {:fields=>{"id"=>0, "first"=>1}}
        got: {:fields=>{"first"=>1}}

Given the tests make this expectation thought I should probably check to see if I'm missing something or I've misdiagnosed my issue (the place I'm running into this is after a Mongoid/origin/etc update on an existing Rails app - a default_scope of ->{ without(:field) } is now causing all sorts of issues due to this breaking whenever .only is called eg to get a list of IDs I'm doing .only(:id) which now throws a MongoDB error).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions