Open jeremos opened 10 months ago
Hi @jeremos , As I remember there was a config for the motor client to handle it properly. Let me double check. Probably I can handle it on Beanie side. Thank you for the catch!
Hi @roman-right I have checked Motor and the only param I found is uuidRepresentation with a default value to UNSPECIFIED. This param is in my sample code and the value to use is "pythonLegacy". So, yep, it's probably on the beanie side. Many thanks
FYI: for this work (at least for us) it's sufficient to initialize beanie as follows:
client = AsyncIOMotorClient(mongo_url, uuidRepresentation="standard")
await init_beanie(database=client.get_database(), document_models=DOCUMENT_MODELS)
I think it should probably still be handled on Beanie's side? And in particular @roman-right, in migrations (beanie/migrations/database.py
) since there beanie itself takes care of initializing the client and so we can't change the parameter (had to resort to monkey-patching the library)
Hi, Thank you again for your work. I noticed a strange result with mongo documents that use UUID as primary keys.
Describe the bug Using UUID as replacement of standard mongo objectId with Linked documents generate bad objects classes when they are fetched.
The first line below show a working result with mongo object ids and two linked documents The second line is the same object model but with UUID for object ids => the doc is not correctly fetched
Here the full script to reproduce
Expected behavior DocWithUUID should be fetched
Additional context Beanie is great !