-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement correct pagination behavior for grouped models #114
Labels
enhancement
New feature or request
Comments
lu-pl
added a commit
that referenced
this issue
Oct 29, 2024
lu-pl
added a commit
that referenced
this issue
Oct 29, 2024
This was referenced Oct 29, 2024
lu-pl
added a commit
that referenced
this issue
Oct 30, 2024
lu-pl
added a commit
that referenced
this issue
Oct 30, 2024
lu-pl
added a commit
that referenced
this issue
Nov 7, 2024
The get_items_query_constructor should be implemented using match/case; in the very likely case that additional query constructors will be needed (e.g. for ordering/filtering etc.), the pattern matching mechanism for model_config provides a pluggable design which allows for easy extension. Closes #114.
lu-pl
added a commit
that referenced
this issue
Nov 8, 2024
lu-pl
added a commit
that referenced
this issue
Nov 8, 2024
lu-pl
added a commit
that referenced
this issue
Nov 8, 2024
lu-pl
added a commit
that referenced
this issue
Nov 8, 2024
lu-pl
added a commit
that referenced
this issue
Nov 8, 2024
lu-pl
added a commit
that referenced
this issue
Nov 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pagination behavior for grouped models currently does not work correctly.
The reason for that is simple: I somehow never got around to implement it. All
rdfproxy
queries are currently generated using the query constructor for ungrouped models. 😬Current behavior
Given the following example model definition
paginating for page 1 of size 2 (
http://localhost:8000/?page=1&size=2
) will yieldpaginating for page 2 of size 2 (
http://localhost:8000/?page=2&size=2
) will yield-- both of which is incorrect.
Expected behavior
The expected result for paginating for page 1 of size 2 (
http://localhost:8000/?page=1&size=2
) isand for paginating for page 2 of size 2 (
http://localhost:8000/?page=2&size=2
):Solution proposal
Paginating grouped models correctly, requires a specific query constructor that constructs and injects a subquery (based on the original query) into the original query.
This touches upon a very fundamental problem
rdfproxy
aims to remedy: SPARQL result sets are inherently flat, i.e. for example in the README example. 6 SPARQL result rows are returned for 3 entities.So the query from which grouped
rdfproxy
models obtain their input must return however many result rows there are for a limited number of entities.E.g the following toy query
returns 4 rows for 3 entities (given that an entity is defined by
parent
). If this is naively limited/offset with size 2, then theSPARQLBindingsMapper
will only receive the first two result rows,('x' 'c' 'foo')
and('y' 'd' UNDEF)
, so the other component of they
entity,('y' 'e' UNDEF)
, simply won't be in the result set of the modified query, leading to the faulty behavior.In order to retrieve however many result rows there are for a limited number of entities, a limited set of entities must be projected from a subquery into the scope of an outer query.
E.g. based on the above query, the
rdfproxy
query constructor needs to dynamically generate the following query:Note
Although the above described feature is certainly doable, I feel like dynamic query generation is the most difficult and brittle part of
rdfproxy
.However, I see no way around dynamic query generation, so that is alright.
Especially query generators need extensive testing though and it might be necessary to use more powerful templating facilities (Jinja) for dynamic query constructors in the future.
The text was updated successfully, but these errors were encountered: