3

我一直在使用 Django 1.3 non-rel 和 django-mongodb_engine 0.4。正在使用的 Mongodb 版本是 1.8.2,一切正常。最近我尝试升级到 mongodb 2.4.2(latest stable) 版本并遇到以下问题。

同步数据库后,我得到以下异常:

Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line    
438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 
379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 191, 
in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 220, 
in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 351,   
in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/commands/syncdb.py", line 90, in handle_noargs
sql, references = connection.creation.sql_create_model(model, self.style, seen_models)
File "/usr/local/lib/python2.7/dist-packages/django_mongodb_engine/creation.py", line 
142, in sql_create_model
self.connection.get_collection(model._meta.db_table, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django_mongodb_engine/base.py", line 98, 
in get_collection
collection = self.collection_class(self.database, name, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 108, in 
__init__
self.__create(kwargs)
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 119, in 
__create
self.__database.command("create", self.__name, **options)
File "/usr/local/lib/python2.7/dist-packages/pymongo/database.py", line 393, in command
msg, allowable_errors)
File "/usr/local/lib/python2.7/dist-packages/pymongo/helpers.py", line 144, in 
_check_command_response
raise OperationFailure(msg % details["errmsg"])
pymongo.errors.OperationFailure: command SON([('create', u'auth_permission'), ('max', 
False), ('capped', False), ('size', 0.0)]) failed: exception: create collection invalid   
size spec

与以前的 mongodb 版本(< 1.8)相比,异常的原因似乎是 mongo 2.X 版本之间的某种不兼容。

从错误中可以看出,有没有办法解决这个有上限/无上限的集合创建问题?

4

1 回答 1

1

目前 createCollection 命令验证 size 参数并将不大于 0 的数字视为无效。

这个 2.3.1 提交开始,如果传入的 size 是一个数字,就会发生 0 检查。以前断言是后来的,这种变化是票证SERVER-7543的结果-核心问题在Django中,在这里进行了深入讨论:https ://github.com/django-nonrel/mongodb-engine/pull/134此处的实际修复:https ://github.com/django-nonrel/mongodb-engine/pull/134/files#L4L134

如果您使用的是包含此修复程序的版本,我认为您需要在 Django 列表中提出问题。

于 2013-05-19T02:04:11.920 回答