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

.only and .without #96

Open
JamesHarrison opened this issue Mar 28, 2014 · 0 comments
Open

.only and .without #96

JamesHarrison opened this issue Mar 28, 2014 · 0 comments
Milestone

Comments

@JamesHarrison
Copy link

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).

@durran durran modified the milestones: 2.0.0, 2.1.0 Mar 31, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants