Skip to content

Conversation

@OJFord
Copy link
Contributor

@OJFord OJFord commented Aug 4, 2016

This PR adds a test for creating and updating a document that has a Falsey primary_key attribute, and fixes it by replacing Boolean-casting existential checks for non-casting checks for NoneType.

Closes #1352.

@OJFord OJFord changed the title Support Falsey primary_keys (closes #1352) Support Falsey primary_keys Aug 4, 2016
@wojcikstefan
Copy link
Member

@OJFord this looks good to me, but the tests are failing. Could you rebase against the latest master?

This commit adds a test for the incorrect behaviour raised in
 #1352, in which updating a document with a `0` primary_key fails
with:
> OperationError: attempt to update a document not yet saved
despite prior saving.

The issue is almost certainly due to a failure to distinguish
between `None` and other falsey values.
Closes #1352; in which updates to such a document would raise an
exception as though it had never been saved.
@OJFord
Copy link
Contributor Author

OJFord commented Dec 3, 2016

@wojcikstefan Looks like the key difference is that the two targets that failed have been dropped (dd473d1); I've rebased anyway.

@wojcikstefan wojcikstefan merged commit d8d98b6 into MongoEngine:master Dec 3, 2016
@wojcikstefan
Copy link
Member

Thank you @OJFord !

@OJFord OJFord deleted the fix-1352 branch December 3, 2016 21:19
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.

Can not update documents with type of pk=int and value 0

2 participants