Comments (3)
Hmm, I haven't really used queries that select multiple entities before.
Our usual approach is to select a single entity and let OData handle any joining and filtering through attributes, e.g.:
For comments/author/name eq 'Tom'
, the visitor would join "comments" and "author" automatically.
We then usually load any relations through the options
method of SQLAlchemy queries, e.g.:
q = apply_odata_query(...).options(joinedload(Comment.author))
.
But your case definitely sounds like something we should support as well! I'll have to think about how this should behave and how we can make it work.
from odata-query.
But your case definitely sounds like something we should support as well! I'll have to think about how this should behave and how we can make it work.
In some way, I made it work... The problem is that I do not know if it behaves has it should.
I made AstToSqlAlchemyClauseVisitor
check many entities looking for an Identifier. I do not think its behaviour is good enough (I am not sure if it is even well defined) to make a PR, but it could be a good starting point. See here. Notice that it is not a branched from master but from the commit closer to the one tagged as v0.5.2 that I found. If you think it is a good idea to make a PR and start a discussion there, just let me know.
from odata-query.
Hey @AndiZeta,
finally found some time to look at your branch.
I think the implementation looks good, and using the OData namespace to select the model is very clever! 👍
One minor thing I would add is to allow passing the model "namespaces" as a dict, instead of always relying on model.__name__
. So maybe accepting the following for the root_model
parameter:
- A single entity: Current behavior, unchanged.
- A collection of entities: The behavior in your branch.
- A dictionary of {namespace: entity}: Behavior in your branch, but using this dict instead of creating it ourselves.
One other thing I'll have to keep in mind is whether this behavior can somehow map onto Django as well, as I'd like to keep the implementations as close as possible.
I'd happily accept a PR, or otherwise I can cook something up myself based on your code when I find some more time.
Thanks again!
from odata-query.
Related Issues (20)
- Disambiguate single-item lists from parenthesized expressions.
- Fully type annotate the library HOT 2
- Better support for `ENUM`s HOT 1
- Does the parser support `contains(field, value)` comparisons? HOT 4
- Question about usage. HOT 2
- Outdated docs HOT 2
- Filter not working for uuid column HOT 6
- Remove Athena specific code HOT 3
- Support for SQLAlchemy Core HOT 2
- Support relationship traversal and `any/all` in SQLAlchemy Core
- Implicit Support for SQLAlchemy's Query-API has been removed HOT 5
- Filter on joined relationship not working for legacy Query objects HOT 3
- apply aggregation support HOT 2
- Definition of sqlalchemy functions_ext overrides desired behaviour HOT 2
- Question about integration HOT 1
- `AstToSqlVisitor` can not handle a function call as right hand side of contains-filter HOT 2
- odata geospatial properties HOT 3
- Missing release tags HOT 1
- Integer values are not parsed correctly HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odata-query.