Issue with uuidRepresentation
robertzak opened this issue · 7 comments
In mongoengine 0.24.1 you added a check for uuidRepresentation in the get_connection_settings
function.
Unfortunately flask-mongoengine is doing a lower() on all connections parameters in the _sanitize_settings
function.
From what I can tell pymongo is actually case insensitive, so while I originally put in a flask-mongoengine issue, I'm wondering if we can maybe just make the if check in mongoengine case insensitive?
I can submit a PR if that would be helpful, I'm just not sure if that's the preferred solution here.
Version info:
Python 3.10.4
Flask 2.1.2
flask-mongoengine 1.0.0
mongoengine 0.24.1
pymongo 4.1.1
Any updates on this? I'm not sure if this repository is still active.
I think something like this should work:
keys = set(key.lower() for key in kwargs.keys())
if "uuidrepresentation" not in keys:
warnings.warn(
"No uuidRepresentation is specified! Falling back to "
"'pythonLegacy' which is the default for pymongo 3.x. "
"For compatibility with other MongoDB drivers this should be "
"specified as 'standard' or '{java,csharp}Legacy' to work with "
"older drivers in those languages. This will be changed to "
"'standard' in a future release.",
DeprecationWarning,
)
kwargs["uuidRepresentation"] = "pythonLegacy"
I'm happy to submit a PR if this is an acceptable solution.
@robertzak yep, something strange seems to happen in mongoengine or in mongo community in total. I do not know, but I feel that there is almost no activity on related project.
Even here, I was out for two years and there was no changes in two years... But I am not alone here )))
So I am not even sure that work that I am currently doing in master has any sense.... But at least I have some codding fun with 'dinosaurs era codebase'.
Ups :) I thought I post it in related project: MongoEngine/flask-mongoengine#451
Thanks for the fix, sorry that it took some time to be merged ;)
No worries, I'm sure maintaining projects like this isn't easy. Any idea on when the fix might be released though?
I'll push a 0.24.2 later today, there is not much compared to 0.24.1 but it doesn't matter. This fix is worth it
Great. Thanks!