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

add support for max, min, last, first operators in aggregation #258

Merged

Conversation

drorasaf
Copy link
Contributor

add support for max, min, last, first operators in aggregation

add last and first aggregation operators support, use six constant
@srinivasreddy
Copy link
Contributor

srinivasreddy commented Sep 1, 2016

Could you pls resolve conflicts ?

@drorasaf drorasaf force-pushed the aggregation_min_max_last_first branch from f8a091e to 730506a Compare September 1, 2016 07:46
@drorasaf
Copy link
Contributor Author

drorasaf commented Sep 1, 2016

I have to mention that test_aggregate10 from the recent commit, outputs:
TypeError: unorderable types: dict() < dict(),
Both on the origin and after the merge

@JulieRossi
Copy link
Contributor

Hi,

This commit comes from a PR I issued. But I don't have that error when I run tests (test_aggregate10 passes).
Did you find out why this error happens ?

Let me know if I can help.

@drorasaf
Copy link
Contributor Author

drorasaf commented Sep 1, 2016

I get this error in python3.
I do not get this error in python2.
This issue is related to differences between python3 and python2.
Python2 allows comparing of dictionaries but incorrectly
@srinivasreddy, have you seen that tox is not defined to run tests with both pymongo and pyexecjs, only with one of them at each time?

@JulieRossi
Copy link
Contributor

Ok, indeed, thanks !
I figured out how to fix it.
I think I will wait for this PR to be merged and then submit a new one to fix this so it doesn't get confusing.

from_field = key.replace('$', '')
if func == "$sum":
current_val = doc_dict.get(field, 0)
for doc in group_list:
Copy link
Contributor

@srinivasreddy srinivasreddy Sep 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc_dict[field] = doc_dict.get(from_field,0) + sum([doc.get(from_field,0) for doc in group_list]) ?

Copy link
Contributor

@srinivasreddy srinivasreddy Sep 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please try for the all functions? does it work? I just did not test it here

@srinivasreddy srinivasreddy merged commit c96ae40 into mongomock:develop Sep 4, 2016
@srinivasreddy
Copy link
Contributor

Thanks

mdomke added a commit that referenced this pull request Sep 14, 2016
* release/3.6.0:
  Bump version to 3.6.0.
  add support for max, min, last, first operators in aggregation (#258)
  add support for $group on embedded dictionaries
  add filter to distinct fix flask8
  add id None argument to aggregation framework support
  fix running tests on python3
  Update Missing_Features.rst
  add missing feature -  operator
  add missing features
  Update travis repo name
  fixes incorrect aggregate function - issue#242
  collection: use python3 division to have an accurate average
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants