Skip to content

Commit 16967dd

Browse files
committed
first draft docs
1 parent 0351a0e commit 16967dd

File tree

5 files changed

+49
-10
lines changed

5 files changed

+49
-10
lines changed

django_mongodb_backend/features.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ class DatabaseFeatures(BaseDatabaseFeatures):
9797
"expressions.tests.ExpressionOperatorTests.test_lefthand_transformed_field_bitwise_or",
9898
}
9999
_django_test_expected_failures_transactions = {
100-
# When get_or_create() fails with IntegrityError, the transaction is no longer usable.
100+
# When update_or_create() fails with IntegrityError, the transaction
101+
# is no longer usable.
101102
"get_or_create.tests.UpdateOrCreateTests.test_manual_primary_key_test",
102103
"get_or_create.tests.UpdateOrCreateTestsWithManualPKs.test_create_with_duplicate_primary_key",
103104
# To investigate (some difference between dbs that do and don't support

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"pymongo": ("https://pymongo.readthedocs.io/en/stable/", None),
4646
"python": ("https://docs.python.org/3/", None),
4747
"atlas": ("https://www.mongodb.com/docs/atlas/", None),
48+
"manual": ("https://www.mongodb.com/docs/manual/", None),
4849
}
4950

5051
root_doc = "contents"

docs/source/ref/database.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,39 @@ effect. Rather, if you need to close the connection pool, use
4141
.. versionadded:: 5.2.0b0
4242

4343
Support for connection pooling and ``connection.close_pool()`` were added.
44+
45+
.. _transactions:
46+
47+
Transactions
48+
============
49+
50+
.. versionadded:: 5.2.0b2
51+
52+
Support for transactions is enabled if the MongoDB configuration supports them:
53+
MongoDB must be configured as a :doc:`replica set <manual:replication>` or
54+
:doc:`sharded cluster <manual:sharding>`, and the store engine must be
55+
:doc:`WiredTiger <manual:core/wiredtiger>`.
56+
57+
If transactions aren't supported (and for any queries run outside of an
58+
:func:`~django.db.transaction.atomic` block), query execution uses Django and
59+
MongoDB's default behavior of autocommit mode. Each query is immediately
60+
committed to the database.
61+
62+
If transactions aren't supported, Django's :doc:`transaction management APIs
63+
<django:topics/db/transactions>` function as no-ops.
64+
65+
Limitations
66+
-----------
67+
68+
MongoDB's transactions have some limitations.
69+
70+
- :meth:`QuerySet.union() <django.db.models.query.QuerySet.union>` is not
71+
supported.
72+
- If a transaction raises an exception, the transaction is no longer usable.
73+
For example, if the update stage of :meth:`QuerySet.update_or_create()
74+
<django.db.models.query.QuerySet.update_or_create>` fails with
75+
:class:`~django.db.IntegrityError` due to a unique constraint violation, the
76+
create stage won't be able to proceed.
77+
:class:`pymongo.errors.OperationFailure` is raised, wrapped by
78+
:class:`django.db.DatabaseError`.
79+
- Savepoints are not supported.

docs/source/releases/5.2.x.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
Django MongoDB Backend 5.2.x
33
============================
44

5+
5.2.0 beta 2
6+
============
7+
8+
*Unreleased*
9+
10+
New features
11+
------------
12+
13+
- Added support for :ref:`database transactions <transactions>`.
14+
515
5.2.0 beta 1
616
============
717

docs/source/topics/known-issues.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,6 @@ Database functions
7777
:class:`~django.db.models.functions.TruncTime` database functions isn't
7878
supported.
7979

80-
Transaction management
81-
======================
82-
83-
Query execution uses Django and MongoDB's default behavior of autocommit mode.
84-
Each query is immediately committed to the database.
85-
86-
Django's :doc:`transaction management APIs <django:topics/db/transactions>`
87-
are not supported.
88-
8980
Database introspection
9081
======================
9182

0 commit comments

Comments
 (0)