-
Notifications
You must be signed in to change notification settings - Fork 78
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
fix: order normalization with descending query #788
Conversation
tests/unit/v1/test_base_query.py
Outdated
|
||
normalized_w_snapshot = query_w_snapshot._normalize_orders() | ||
expected_w_snapshot = expected + [ | ||
query._make_order("b", "DESCENDING"), |
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.
let me know if this test case looks right.
Previously we were always using ASCENDING for all added orders. My understanding is we should always use the previous direction?
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.
Nit: IMO it would be more readable just to spell out the whole expected list here instead of appending the previous expected
.
orders.append(self._make_order("__name__", direction)) | ||
# skip equality filters and filters on fields already ordered | ||
if ( | ||
filter_.op not in _EQUALITY_OPERATORS |
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.
In my opinion, it would be better to create a list of INEQUALITY filters such that a new filter is default opted out rather than default opted in. This matches how other SDKs handle this more closely. I also think it's more likely someone will notice that an inequality is not having the order-by normalized rather than an equality filter is accidentally sneaking into the order-by normalization (Since it's an equality, the ordering is not easily noticed in most situations.)
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.
makes sense, fixed
tests/unit/v1/test_base_query.py
Outdated
_make_base_query(collection) | ||
.where(filter=FieldFilter("a", "==", 1)) | ||
.where(filter=FieldFilter("b", "in", [1, 2, 3])) | ||
.where(filter=FieldFilter("b", "not-in", [4, 5, 6])) |
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.
Nit: We have two 'b' values here, an equality and inequality on the same field, it would probably make more sense to have this be a separate property value.
This PR fixes a bug in order normalization logic, to be more in line with nodejs: