Skip to content

Commit 8551738

Browse files
authored
Merge pull request #2857 from bagerard/remove_longfield
remove longfield
2 parents ea4e719 + 52007ed commit 8551738

File tree

6 files changed

+25
-82
lines changed

6 files changed

+25
-82
lines changed

docs/apireference.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ Fields
7777
.. autoclass:: mongoengine.fields.EmailField
7878
.. autoclass:: mongoengine.fields.EnumField
7979
.. autoclass:: mongoengine.fields.IntField
80-
.. autoclass:: mongoengine.fields.LongField
8180
.. autoclass:: mongoengine.fields.FloatField
8281
.. autoclass:: mongoengine.fields.DecimalField
8382
.. autoclass:: mongoengine.fields.Decimal128Field

docs/changelog.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Development
1212
- make sure to read https://www.mongodb.com/docs/manual/core/transactions-in-applications/#callback-api-vs-core-api
1313
- run_in_transaction context manager relies on Pymongo coreAPI, it will retry automatically in case of `UnknownTransactionCommitResult` but not `TransientTransactionError` exceptions
1414
- Using .count() in a transaction will always use Collection.count_document (as estimated_document_count is not supported in transactions)
15-
- Further to the deprecation warning, remove ability to use an unpacked list to `Queryset.aggregate(*pipeline)`, a plain list must be provided instead `Queryset.aggregate(pipeline)`, as it's closer to pymongo interface
16-
- Further to the deprecation warning, remove `full_response` from `QuerySet.modify` as it wasn't supported with Pymongo 3+
15+
- BREAKING CHANGE: Further to the deprecation warning, remove ability to use an unpacked list to `Queryset.aggregate(*pipeline)`, a plain list must be provided instead `Queryset.aggregate(pipeline)`, as it's closer to pymongo interface
16+
- BREAKING CHANGE: Further to the deprecation warning, remove `full_response` from `QuerySet.modify` as it wasn't supported with Pymongo 3+
1717
- Fixed stacklevel of many warnings (to point places emitting the warning more accurately)
1818
- Add support for collation/hint/comment to delete/update and aggregate #2842
1919
- BREAKING CHANGE: Remove LongField as it's equivalent to IntField since we drop support to Python2 long time ago (User should simply switch to IntField) #2309

docs/guide/defining-documents.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ are as follows:
8888
* :class:`~mongoengine.fields.ImageField`
8989
* :class:`~mongoengine.fields.IntField`
9090
* :class:`~mongoengine.fields.ListField`
91-
* :class:`~mongoengine.fields.LongField`
9291
* :class:`~mongoengine.fields.MapField`
9392
* :class:`~mongoengine.fields.ObjectIdField`
9493
* :class:`~mongoengine.fields.ReferenceField`

mongoengine/fields.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import pymongo
1515
from bson import SON, Binary, DBRef, ObjectId
1616
from bson.decimal128 import Decimal128, create_decimal128_context
17-
from bson.int64 import Int64
1817
from pymongo import ReturnDocument
1918

2019
try:
@@ -68,7 +67,6 @@
6867
"URLField",
6968
"EmailField",
7069
"IntField",
71-
"LongField",
7270
"FloatField",
7371
"DecimalField",
7472
"BooleanField",
@@ -367,13 +365,6 @@ def prepare_query_value(self, op, value):
367365
return super().prepare_query_value(op, int(value))
368366

369367

370-
class LongField(IntField):
371-
"""64-bit integer field. (Equivalent to IntField since the support to Python2 was dropped)"""
372-
373-
def to_mongo(self, value):
374-
return Int64(value)
375-
376-
377368
class FloatField(BaseField):
378369
"""Floating point number field."""
379370

tests/fields/test_int_field.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
from bson import Int64
23

34
from mongoengine import *
45
from tests.utils import MongoDBTestCase
@@ -42,3 +43,25 @@ class TestDocument(Document):
4243

4344
assert 1 == TestDocument.objects(int_fld__ne=None).count()
4445
assert 1 == TestDocument.objects(int_fld__ne=1).count()
46+
47+
def test_int_field_long_field_migration(self):
48+
class DeprecatedLongField(IntField):
49+
"""64-bit integer field. (Equivalent to IntField since the support to Python2 was dropped)"""
50+
51+
def to_mongo(self, value):
52+
return Int64(value)
53+
54+
class TestDocument(Document):
55+
long = DeprecatedLongField()
56+
57+
TestDocument.drop_collection()
58+
TestDocument(long=10).save()
59+
60+
v = TestDocument.objects().first().long
61+
62+
# simulate a migration to IntField
63+
class TestDocument(Document):
64+
long = IntField()
65+
66+
assert TestDocument.objects(long=10).count() == 1
67+
assert TestDocument.objects().first().long == v

tests/fields/test_long_field.py

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)