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

Mixing foreign and local object ids breaks querying #1345

ehiggs opened this issue Jan 6, 2020 · 0 comments

Mixing foreign and local object ids breaks querying #1345

ehiggs opened this issue Jan 6, 2020 · 0 comments


Copy link

@ehiggs ehiggs commented Jan 6, 2020

As a developer, I want Eve to do no objectid coercion aside from id fields so that I can store foreign mongo ids and still have post and get working.


On from #599, #600, #1164, it's not uncommon to have a service that allows clients to put data to the server and give the data handles determined by the client. If the client side developers are also using mongodb then it's a real use case to have strings that can be parsed as objectid but that we don't want to have as objectids.

This works with query_objectid_as_string however in more complicated queries where we mix in actual objectids, it can break.

The fix here looks like it does the simplest thing that could work by checking to see if the type being gotten is an id field and if it is, always cast to objectid.

Example use case

A photo service where users can set a handle for the photos. A client uploads the photo and sets the handle as their local objectid. On the server (Eve) side, the user id is an _id. And the photo id is a string. The resulting request would fail with query_objectid_as_string set to either False or True:

curl 'https://localhost:8080/photos?where={"photo_handle": {"$in": ["12345678912"]}, "user": {"$in": ["21987654321"]}}'

I think the prototype posted in #1164 would fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants