-
Notifications
You must be signed in to change notification settings - Fork 26
INTPYTHON-348 add support for QuerySet.raw_mql() #173
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
Conversation
This project was changed (9f0ad73) to use I'm not sure that really answers your question, but if you can't figure out how to connect the implementation pieces from this tip, I'll have to dive into the code and take a longer look. |
Right, for example folks can pass in an aggregation pipeline, I assume, e.g.
That helps! A MongoQuery's
When someone writes |
The user could write |
@Jibola pointed out that @timgraham pointed out nonrel already supports this, so here is a 2nd pass. Aside from using
instead of a mixin, I think this is nonrel's implementation. In my testing, I get this output:
Thanks both! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When it's working you should see your query reflected like this: {'$match': {'question_text': ""}}
.
I actually think the approach here should even remove the We should have the expectation be truly "hands free". i.e.
Ahhh, I see what you mean now. It only supports match conditions because it still has to fit into the returned object. I think that's good to highlight. I will still say, to my previous point, I'd still rather we remove the guardrails. This way, we can use the translations to even empower them to do groups/projections that fit the object. (That's hacky, but I see this being useful for folks using $search/$vectorSearch operators that would want to do this) |
Yes, we could require the user to provide an entire pipeline. Perhaps the first step is to read the |
Yeah! based on the documentation, my rough understanding is that we can append the $project to maintain expected fields. |
Right. This will have the same caveat from the Django docs as when the user provides a SQL statement: "No checking is done on the pipeline that is passed in to .raw(). Django expects that the pipeline will return a set of documents from the database, but does nothing to enforce that. If the query does not return documents, a (possibly cryptic) error will result." |
I'm in favor of allowing foot guns here, but I want to clarify that if the end user writes MQL that references data that is not managed by Django, we return an empty query set correct? |
I'm not sure exactly what you have in mind, but I'd focus on matching the behavior in the |
- Update raw_mql function signature
Superseded by #183 |
For #163. This PR adds a new file
manager.py
with classMongoManager
and updatesquery.py
to include classeswhich returns:
which perhaps can be fixed by ensuring
cursor
is a MongoDBcursor
and/or query is aMongoQuery
. Is this a good approach or am I missing a shorter path to returning iterable results ofraw_mql
query?