-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added draft DEP for external query languages support by Django ORM #40
base: main
Are you sure you want to change the base?
Conversation
Hi @Nepherhotep Have you thought about ExpressionBuilders being Left right here - Django would not actually need to change any code at all. Since the library would have access to the current query object, it'd know the entire state of the query, have access to the model, and the Meta class of that model. If above serves our purposes, then I think it'd be worth looking more closely into The ExpressionBuilder library would then maintain state internally of the property accesses and method calls, keeping an AST of sorts internally. For each property it'd be able to call A different library could also just convert the internal representation into a kwarg, and let django handle the resolving of each part - incurring more overhead but would seemingly be quicker to iterate on and get feedback for. |
I wonder if this might make the stuff @jarshwah and I have discussed before about allowing, for example, an Exists subquery to be used as a filter directly, instead of the annotate, filter dance we currently have to do. |
I believe Resolvable will work, the critical thing here - ExpressionBuilder should not be of the whole Expression interface, as that class is quite complicated and it would be more difficult to extended it for third-party libraries (due to possible method conflicts, for example). |
You might be interested in django-model-values' F expressions, as a reference implementation of essentially the same idea. The only difference is I choose to just subclass |
Cool library @coady! I'll definitely be taking a closer look. |
A mix of both approaches might be great |
I want to give this approach a shot you provide a green signal. |
we may also take https://github.com/thedrow/django-natural-query into consideration |
Hey @jarshwah @akaariai
Here is a DEP describing the possible API for third-party query language support by Django ORM. If you like the idea it would be great if we can arrange phone/skype call to discuss some technical details, as the proposal touches code which I don't fully understand - basically it's stuff related to joins.
Best regards,
Alexey