| @@ -552,7 +552,9 @@ class DictField(ComplexBaseField): | |||||||
|         if not isinstance(value, dict): |         if not isinstance(value, dict): | ||||||
|             self.error('Only dictionaries may be used in a DictField') |             self.error('Only dictionaries may be used in a DictField') | ||||||
|  |  | ||||||
|         if any(('.' in k or '$' in k) for k in value): |         if any(k for k in value.keys() if not isinstance(k, basestring)): | ||||||
|  |             self.error('Invalid dictionary key - documents must have only string keys') | ||||||
|  |         if any(('.' in k or '$' in k) for k in value.keys()): | ||||||
|             self.error('Invalid dictionary key name - keys may not contain "."' |             self.error('Invalid dictionary key name - keys may not contain "."' | ||||||
|                        ' or "$" characters') |                        ' or "$" characters') | ||||||
|         super(DictField, self).validate(value) |         super(DictField, self).validate(value) | ||||||
|   | |||||||
| @@ -636,6 +636,9 @@ class FieldTest(unittest.TestCase): | |||||||
|         post.info = {'the.title': 'test'} |         post.info = {'the.title': 'test'} | ||||||
|         self.assertRaises(ValidationError, post.validate) |         self.assertRaises(ValidationError, post.validate) | ||||||
|  |  | ||||||
|  |         post.info = {1: 'test'} | ||||||
|  |         self.assertRaises(ValidationError, post.validate) | ||||||
|  |  | ||||||
|         post.info = {'title': 'test'} |         post.info = {'title': 'test'} | ||||||
|         post.save() |         post.save() | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user