Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Support for $slice-ing ListFields #97

Open
jonashaag opened this Issue Dec 26, 2011 · 3 comments

Comments

Projects
None yet
2 participants
Contributor

jonashaag commented Dec 26, 2011

It should be possible to pass a second parameter to raw_query() specifying a list of fields to include (similar to Django's values()).

I see two possibilities for implementing this:

  • Restricting the arguments passed that way to $slice and similar; not allowing boolean include/exclude flags -- these could be passed using values()
  • Allowing anything PyMongo accepts as fields. Needs some extra work to make Django return a ValuesQuerySet

In both cases we'd need to merge the fields passed to raw_query and values (if called).

Owner

flaper87 commented Dec 26, 2011

besides, raw_query() should also be implemented inside the MongoDBQuerySet. A good use case of this could be:

results = MyModel.objects.using("mydb").raw_query({ "foo" : bar })

Perhaps we should also override the using method just to make sure the specified db is a mongodb one. Does this make sense?

We could open a new issue for the using method extension.

Contributor

jonashaag commented Dec 26, 2011

I agree that raw_query should be implemented inside the QS; at least it should be possible to use using for raw queries as well (which is possible if we move the code into the QS).

I'm not sure I like the using check; it's going to crash anyway at some point if you try to execute a raw Mongo query on a SQL database ;) So if the error message is clear enough I don't think we need it. Otherwise I'm okay with adding the explicit check.

Owner

flaper87 commented Dec 26, 2011

I'm not sure about this but, shouldn't the using method use the router to check whether that model can read/write in the requested DB? I think it does.

About the raw_query in the QS, I did that already, I should clean the code a little bit more and commit it (it's already in production, I just haven't had the time to commit it).

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