Django非rel不能与mongo 2.4.2同步db

时间:2013-04-22 12:20:13

标签: python django mongodb django-nonrel django-mongodb-engine

我一直在使用Django 1.3非rel与django-mongodb_engine 0.4。正在使用的Mongodb版本是1.8.2并且工作正常。最近我尝试升级到mongodb 2.4.2(最新稳定版)并面临以下问题。

同步db后,我得到以下异常:

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

异常的原因似乎是mongo 2.X版本与之前的mongodb版本(&lt; 1.8)之间存在某种不兼容性。

从错误中可以明显看出这个上限/无上限集合创建问题吗?

1 个答案:

答案 0 :(得分:1)

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

this 2.3.1 commit开始,如果传入的大小是数字,则会发生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列表中提出问题。