Skip to content

Commit b03e598

Browse files
committed
PYTHON-2748 Fix error in UUID example (#650)
(cherry picked from commit 00f7fe8)
1 parent 1b2a599 commit b03e598

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

doc/examples/uuid.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,19 +255,27 @@ Applications can set the UUID representation in one of the following ways:
255255
* - ``unspecified``
256256
- :ref:`unspecified-representation-details`
257257

258-
#. Using the ``uuid_representation`` kwarg option, e.g.::
258+
#. At the ``MongoClient`` level using the ``uuidRepresentation`` kwarg
259+
option, e.g.::
259260

260261
from bson.binary import UuidRepresentation
261-
client = MongoClient(uuid_representation=UuidRepresentation.PYTHON_LEGACY)
262+
client = MongoClient(uuidRepresentation=UuidRepresentation.PYTHON_LEGACY)
262263

263-
#. By supplying a suitable :class:`~bson.codec_options.CodecOptions`
264-
instance, e.g.::
264+
#. At the ``Database`` or ``Collection`` level by supplying a suitable
265+
:class:`~bson.codec_options.CodecOptions` instance, e.g.::
265266

266267
from bson.codec_options import CodecOptions
267268
csharp_opts = CodecOptions(uuid_representation=UuidRepresentation.CSHARP_LEGACY)
269+
java_opts = CodecOptions(uuid_representation=UuidRepresentation.JAVA_LEGACY)
270+
271+
# Get database/collection from client with csharpLegacy UUID representation
268272
csharp_database = client.get_database('csharp_db', codec_options=csharp_opts)
269273
csharp_collection = client.testdb.get_collection('csharp_coll', codec_options=csharp_opts)
270274

275+
# Get database/collection from existing database/collection with javaLegacy UUID representation
276+
java_database = csharp_database.with_options(codec_options=java_opts)
277+
java_collection = csharp_collection.with_options(codec_options=java_opts)
278+
271279
Supported UUID Representations
272280
------------------------------
273281

0 commit comments

Comments
 (0)