MongoEngine / MongoEngine/mongoengine
Store UUID mongo type, not LUUID ? Or how to use CodecOptions?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
Hello.
I can't figure out, how to store Python's UUID() as MongoDB's UUID()? For now it is stored as BinData(3, '...=')
Legacy Way:
db.collection.find().pretty():
{
...
"some_uuid_field": BinData(3, "...="),
...
}
Modern Way:
db.collection.find().pretty():
{
...
"some_uuid_field": UUID("..."),
...
}
I've found that in pymongo we can pass CodecOptions with uuid_representation=bson.STANDARD, but how to use CodecOptions with Mongoengine?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing MongoEngine's connection and UUID handling paths, then compare the legacy BinData representation with PyMongo's CodecOptions behavior described in the issue. Clarify the intended configuration and define done as a supported way to store Python UUID values using MongoDB's standard UUID representation, with tests covering the resulting encoding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100