Fix long fields stored as int32 in Python 3. issue #1253

This commit is contained in:
Gilbert Gilb's
2016-03-15 14:34:22 +01:00
committed by Gilb's
parent c6cc0133b3
commit 7cc1a4eba0
3 changed files with 19 additions and 1 deletions

View File

@@ -19,7 +19,7 @@ else:
import pymongo
import gridfs
from bson import Binary, DBRef, SON, ObjectId
from bson import Binary, DBRef, SON, ObjectId, Int64
from mongoengine.errors import ValidationError
from mongoengine.python_support import (PY3, bin_type, txt_type,
@@ -227,6 +227,9 @@ class LongField(BaseField):
pass
return value
def to_mongo(self, value, **kwargs):
return Int64(value)
def validate(self, value):
try:
value = long(value)