-
Notifications
You must be signed in to change notification settings - Fork 9
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
refactor query generation #33
Conversation
f62c157
to
74a3dfa
Compare
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.
Left open comments, but everything looks good so far!
@@ -139,209 +95,56 @@ def get_cursor(self): | |||
cursor.limit(int(self.query.high_mark - self.query.low_mark)) | |||
return cursor | |||
|
|||
def add_filters(self, filters, query=None): |
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.
I don't see the add_filters method anymore. Is it no longer needed? Was this the function that got originally called on the WhereNode
instruction?
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.
Yes, see django_mongodb/compiler.py old line 139.
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.
Yes, it is not longer needed, We have changed it using the as_mql method and it recursive structure. So, add filters was replaced by as_mql method of the WhereNode. This way to compute the filter is more Django like taking advantage of the tree structure.
if lookup_name not in ("in", "range"): | ||
value = value[0] |
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.
All values come through as List[Any] types?
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.
See comment two lines above. This is copied from the old _normalize_lookup_value()
.
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.
Well, yeah, the thing is:
We use a Django method to normalize things, those methods returns: (sql_string, [parameters]) And we only need the parameters, and there is an especial case with in and range, that [parameters] must keeps as an array.
Django return the value in the way that sql_string % params works. So we need to unfold this structure.
854317a
to
7c833f4
Compare
fixes mongodb-labs#13, mongodb-labs#22 Co-authored-by: Tim Graham <[email protected]>
7c833f4
to
3789b9f
Compare
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.
Great work!
fixes #13, #22