db2 does not allow None as a key for user_id in user collection

mongodb allows None value as a key for _id field, but db2 does not.
this patch will fix the problem when meters coming with user_id
being set to None.

Change-Id: If48e5117198f3e9ad834e4f7fa58ec27c57a8bc8
fixes: bug #1234165
This commit is contained in:
Tong Li 2013-10-02 09:18:14 -04:00
parent 0186c0e54b
commit 77a0603beb

View File

@ -307,7 +307,7 @@ class Connection(base.Connection):
"""
# Make sure we know about the user and project
self.db.user.update(
{'_id': data['user_id']},
{'_id': data['user_id'] or 'null'},
{'$addToSet': {'source': data['source'],
},
},
@ -325,7 +325,7 @@ class Connection(base.Connection):
self.db.resource.update(
{'_id': data['resource_id']},
{'$set': {'project_id': data['project_id'],
'user_id': data['user_id'],
'user_id': data['user_id'] or 'null',
'metadata': data['resource_metadata'],
'source': data['source'],
},