-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Delete returns None but expected a dict #1008
Comments
This is strange, we have test covering that... I'm wondering why pymongo returns None. Thanks for reporting @Garito |
Glad to help I've tryed to install pymongo lastest version but it raises some errors (sorry for don't provide the traceback) perhaps will be this? |
immm I have absolutely no idea of flask-mongoengine and what it could add... |
Could it be the convination of pymongo 2.8 and mongodb 3.0? |
It shouldn't, as it is quite common and I myself used that for a while, 2015-06-02 12:18 GMT+02:00 Garito notifications@github.com:
|
Is there anything I could do to provide you more info? Thanks! |
@Garito I have really no idea why it is None at that point. It seems to be inside pymongo...
|
Before to try to install pymongo and so on I've tryed to print the queryset._query and write_concert in case this info as it is could be useful: Is this useful? Thanks! |
With pymongo=3.0.2 and -e git://github.com/mongoengine/mongoengine.git@03ed5c3#egg=mongoengine-master it raises another different error: Any ideas? |
Really weird it doesn't return anything on such a simple and straight-forward delete query... PyMongo or MongoDB internal problem !?!? Regarding the second one, immm this is not possible... the actual master has the fix for _Cursor__snapshot... Could you please paste the full stack trace for the AttributeError and eventually verify that the file raising the _Cursor__snapshot error is the same than in the repo? Also deleting .pyc files and so on before |
Let me know if I've done the mongoengine's master branch install correctly, please: |
Let me copy the whole log since I've started the flask app till the error. Remember that now this error is raised no matter what I ask for to Flask. The logs:
|
OK, yep, the flask-mongoengine app is not that far and does not support PyMongo3 for now. It is not related or due to mongoengine itself... That's a pity, it would have been cool to test it, we may have had at least a more specific output. Sorry, I didn't knew about that. I really don't know what to recommend you to do, I see two possibilities:
|
So to recap: am I correct? |
Almost ;-)
|
I see Sorry for asking too much on this point but I'm scared to death on this task since seems to me a very dark case which everyone will defend themselves before admit it (since is an edge case) Do you recommend a protocol to reduce the friction or something? |
Indeed tough questions :-) I would do both in parallel:
This is how I see minimal friction, but still not trivial |
Whenever you think it doesn't concern anymore mongoengine, like after or in case I don't have to review the PR for flask-mongoengine, also please close the ticket, that you may reopen if you have newer information or output from MongoDB Inc... |
Hi! Returns:
So it is not a bug that pymongo's collection.remove returns None if the write acknowledgement is disable but mongoengine doesn't have this case into account so I have to conclude that the bug is on mongoengine What do you think? |
BTW the change to solve this issue will be to update line 464 of queryset/base.py from return result["n"] to return result["n"] if result and "n" in result else result I think this update will be correct giving the fact that if write_concern is empty or 0 it's ok to return None so result will be None if the write_concern is 0 or {} (which is my actual case) I've made this modification in my installed library to test and it works ok for me |
Hi! Thanks! |
Ok so what we need you to do right now it to supply a test case that attempts to delete an object while specifying a write concern. |
Yes, please write a test with your diff and submit it as a PullRequest. If it is your first time, github has some tutorials on how to do it. It is quite easy, you'll see. There is also a contributing doc in mongoengine repository. One thing, for your change, the following is enough:
as None is the default return value in python. If you could do it in the next 7 days, it would even make it it into the next big release, the 0.10 |
Will try |
Thank to you @MRigal! Nice to be useful |
@Garito When the bug fix will be merged. |
I'm trying to delete a document with self.delete() but it raises and error:
File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 467, in delete
return result["n"]
TypeError: 'NoneType' object has no attribute 'getitem'
I've checked the result with print result and it is None
The deletion is made ok but the try to return result["n"] raises and error because result is None
Did I missed something or did I find a bug?
Thanks!
The text was updated successfully, but these errors were encountered: