Skip to content

Conversation

@wojcikstefan
Copy link
Member

@wojcikstefan wojcikstefan commented Feb 7, 2017

Fixes #1469 #1475 and reverses an invalid "fix" from #1049

Main changes:

  • BaseQuerySet.limit/skip/hint/batch_size are now chained properly.
  • BaseQuerySet.order_by now allows clearing a previously specified ordering (not just the default ordering as it used to).
  • Public BaseQuerySet.clone_into method has been renamed to a private _clone_into (shouldn't have been public in the first place).
  • BaseQuerySet._get_order_by method doesn't manipulate the cursor anymore (that was a poorly designed separation of concerns).

key_list.append((key, direction))

if self._cursor_obj and key_list:
self._cursor_obj.sort(key_list)

Choose a reason for hiding this comment

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

can you explain why this is being removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Glad you asked :) Manipulating the cursor within this method makes for a poor separation of concerns. I would not expect to change the state of the cursor just by trying to convert MongoEngine-like sort keys to PyMongo-like sort tuples. That job is better left to BaseQuerySet.order_by, which is where I moved it (https://github.com/MongoEngine/mongoengine/pull/1476/files#diff-05c70acbd0634d6d05e4a6e3a9b7d66bR1007)

@liuhelen10
Copy link

the chaining fixes re: broken .limit LGTM 👍 thanks for addressing!

@wojcikstefan wojcikstefan changed the title WIP Fix cursor management Fix cursor management Feb 8, 2017
@wojcikstefan wojcikstefan merged commit 3ca2e95 into master Feb 9, 2017
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.

BaseQuerySet._cursor_obj inconsistent handling with query methods, e.g. skip and limit?

4 participants