Fix bug introduced in -1.19 related to DictField validate failing without default connection
This commit is contained in:
		| @@ -1088,14 +1088,12 @@ class DictField(ComplexBaseField): | ||||
|             msg = "Invalid dictionary key - documents must have only string keys" | ||||
|             self.error(msg) | ||||
|  | ||||
|         curr_mongo_ver = get_mongodb_version() | ||||
|  | ||||
|         if curr_mongo_ver < MONGODB_36 and key_has_dot_or_dollar(value): | ||||
|             self.error( | ||||
|                 'Invalid dictionary key name - keys may not contain "."' | ||||
|                 ' or startswith "$" characters' | ||||
|             ) | ||||
|         elif curr_mongo_ver >= MONGODB_36 and key_starts_with_dollar(value): | ||||
|         # Following condition applies to MongoDB >= 3.6 | ||||
|         # older Mongo has stricter constraints but | ||||
|         # it will be rejected upon insertion anyway | ||||
|         # Having a validation that depends on the MongoDB version | ||||
|         # is not straightforward as the field isn't aware of the connected Mongo | ||||
|         if key_starts_with_dollar(value): | ||||
|             self.error( | ||||
|                 'Invalid dictionary key name - keys may not startswith "$" characters' | ||||
|             ) | ||||
|   | ||||
| @@ -11,7 +11,7 @@ MONGODB_36 = (3, 6) | ||||
|  | ||||
|  | ||||
| def get_mongodb_version(): | ||||
|     """Return the version of the connected mongoDB (first 2 digits) | ||||
|     """Return the version of the default connected mongoDB (first 2 digits) | ||||
|  | ||||
|     :return: tuple(int, int) | ||||
|     """ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user