【问题标题】:Django non-rel failing to sync db with mongo 2.4.2Django non-rel 无法将 db 与 mongo 2.4.2 同步
【发布时间】:2013-04-22 12:20:12
【问题描述】:

我一直在使用 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

异常的原因似乎是 mongo 2.X 版本与以前的 mongodb 版本(

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

【问题讨论】:

  • 这里有同样的问题。我不知道如何解决这个问题

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


【解决方案1】:

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

this 2.3.1 commit 开始,如果传入的 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-09-29
    • 1970-01-01
    • 1970-01-01
    • 2014-11-07
    • 1970-01-01
    • 1970-01-01
    • 2020-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多