Improve mapped column handling for REST pagination and NextLink creation fixes#1319
Merged
seantleonard merged 24 commits intomainfrom Mar 23, 2023
Merged
Conversation
…he returned db result. Should be mapped value not unmapped value. Then addressed uncovered encoding differences in tests vs engine and made consistent. i.e. `%3d` vs correctly upper case `%3D`
aaronburtle
approved these changes
Mar 10, 2023
Contributor
aaronburtle
left a comment
There was a problem hiding this comment.
Nice find, thanks for fixing!
abhishekkumams
approved these changes
Mar 10, 2023
Contributor
abhishekkumams
left a comment
There was a problem hiding this comment.
Interesting Find.
severussundar
approved these changes
Mar 10, 2023
Aniruddh25
reviewed
Mar 11, 2023
Aniruddh25
reviewed
Mar 11, 2023
Aniruddh25
requested changes
Mar 11, 2023
Collaborator
Aniruddh25
left a comment
There was a problem hiding this comment.
Thanks for fixing so quickly, waiting for addition of tests
…ected behavior of correct nextlink generation.
This was referenced Mar 17, 2023
…tity to all setup scripts for all db flavors and update reference configuration files.
…r used in the nextLink pagination cursor. Tests added for all db flavors, sql config references updated with new entities that are used in tests, and commands in config generation scripts are updated.
…ttps://github.com/Azure/data-api-builder into dev/seleonar/issue1315_restpagination_keynotfound
Aniruddh25
reviewed
Mar 17, 2023
Aniruddh25
reviewed
Mar 17, 2023
Aniruddh25
reviewed
Mar 17, 2023
Aniruddh25
reviewed
Mar 18, 2023
Aniruddh25
approved these changes
Mar 18, 2023
…ms and is also not the first. Which checks for alternative prefix to after query param: &$ and not ?$
Aniruddh25
approved these changes
Mar 18, 2023
Collaborator
Aniruddh25
left a comment
There was a problem hiding this comment.
LGTM, after simplifying the config files!
…at was using the type table.
…rators as they are no present in the test project.
… dev/seleonar/issue1315_restpagination_keynotfound
… to not result in CICD errors.
…and mappedbookmarks table because generate_series is only compatible with sql2022 and not sql2019/localdb
Aniruddh25
approved these changes
Mar 23, 2023
Aniruddh25
pushed a commit
that referenced
this pull request
Mar 24, 2023
…ion fixes (#1319) ## Why make this change? - Closes #1315 which highlights an issue with pagination logic not resolving column names from database results using "mapped" column names, when configured. Instead, the current column resolution always uses "backing" column names. ## What is this change? - changes `TryResolveJsonElementToScalarVariable(element.GetProperty(column)` - to: `TryResolveJsonElementToScalarVariable(element.GetProperty(exposedColumnName)` ### Issue when loading request "FindMany" within pagination token With a request like ` GET https://localhost:5001/api/todo` This result is returned as next link: ```json "nextLink": "https://localhost:5001/api/todo?System.Collections.Specialized.NameValueCollection" ``` - Fixing the column resolution uncovered this bug with how **initial** pagination next links are generated. (not a problem when a pagination link is included with request). The `NameValueCollection` which contains all query string key/value pairs was not being resolved into a query string and the nextLink looked like: `"nextLink": "https://localhost:5001/api/todo/System.Collections.Specialized.NameValueCollection"` - The fix was to add explicit iteration of the key value pairs in the collection and generate a well-formed Query String using AspNetCore helper utilities. - This uncovered a subtle difference in how the engine and test fixture escape query string payload for URLs. Tests were using a helper which incorrectly escaped invalid URI characters with lower case hex value. i.e. `%3d`. Then proper form would be uppercase -> `%3D` - Discussion https://stackoverflow.com/a/48301702/18174950 - https://stackoverflow.com/a/47877559/18174950 - https://edi.wang/post/2018/11/25/netcore-webutility-urlencode-httputility-urlencode - https://stackoverflow.com/a/51829522/18174950 ## How was this tested? - [x] Integration Tests- updated existing integration tests. - [ ] Unit Tests ## Sample Request(s) - Using the configuration/SQL db script provided in the issue, the following request will succeed now and provide a valid NextLink: `https://localhost:5001/api/todo?$orderby=title desc, tid asc`
Aniruddh25
pushed a commit
that referenced
this pull request
Mar 24, 2023
…ion fixes (#1319) - Closes #1315 which highlights an issue with pagination logic not resolving column names from database results using "mapped" column names, when configured. Instead, the current column resolution always uses "backing" column names. - changes `TryResolveJsonElementToScalarVariable(element.GetProperty(column)` - to: `TryResolveJsonElementToScalarVariable(element.GetProperty(exposedColumnName)` With a request like ` GET https://localhost:5001/api/todo` This result is returned as next link: ```json "nextLink": "https://localhost:5001/api/todo?System.Collections.Specialized.NameValueCollection" ``` - Fixing the column resolution uncovered this bug with how **initial** pagination next links are generated. (not a problem when a pagination link is included with request). The `NameValueCollection` which contains all query string key/value pairs was not being resolved into a query string and the nextLink looked like: `"nextLink": "https://localhost:5001/api/todo/System.Collections.Specialized.NameValueCollection"` - The fix was to add explicit iteration of the key value pairs in the collection and generate a well-formed Query String using AspNetCore helper utilities. - This uncovered a subtle difference in how the engine and test fixture escape query string payload for URLs. Tests were using a helper which incorrectly escaped invalid URI characters with lower case hex value. i.e. `%3d`. Then proper form would be uppercase -> `%3D` - Discussion https://stackoverflow.com/a/48301702/18174950 - https://stackoverflow.com/a/47877559/18174950 - https://edi.wang/post/2018/11/25/netcore-webutility-urlencode-httputility-urlencode - https://stackoverflow.com/a/51829522/18174950 - [x] Integration Tests- updated existing integration tests. - [ ] Unit Tests - Using the configuration/SQL db script provided in the issue, the following request will succeed now and provide a valid NextLink: `https://localhost:5001/api/todo?$orderby=title desc, tid asc`
Aniruddh25
added a commit
that referenced
this pull request
Mar 24, 2023
## Why make this change? Cherry picking the following changes to create a patch for 0.5.x: - #1349 - #1319 - #1351 --------- Co-authored-by: Jun Su <70380073+junsu0ms@users.noreply.github.com> Co-authored-by: Sean Leonard <sean.leonard@microsoft.com> Co-authored-by: abhishekkumams <102276754+abhishekkumams@users.noreply.github.com>
abhishekkumams
pushed a commit
that referenced
this pull request
Mar 30, 2023
…ion fixes (#1319) ## Why make this change? - Closes #1315 which highlights an issue with pagination logic not resolving column names from database results using "mapped" column names, when configured. Instead, the current column resolution always uses "backing" column names. ## What is this change? - changes `TryResolveJsonElementToScalarVariable(element.GetProperty(column)` - to: `TryResolveJsonElementToScalarVariable(element.GetProperty(exposedColumnName)` ### Issue when loading request "FindMany" within pagination token With a request like ` GET https://localhost:5001/api/todo` This result is returned as next link: ```json "nextLink": "https://localhost:5001/api/todo?System.Collections.Specialized.NameValueCollection" ``` - Fixing the column resolution uncovered this bug with how **initial** pagination next links are generated. (not a problem when a pagination link is included with request). The `NameValueCollection` which contains all query string key/value pairs was not being resolved into a query string and the nextLink looked like: `"nextLink": "https://localhost:5001/api/todo/System.Collections.Specialized.NameValueCollection"` - The fix was to add explicit iteration of the key value pairs in the collection and generate a well-formed Query String using AspNetCore helper utilities. - This uncovered a subtle difference in how the engine and test fixture escape query string payload for URLs. Tests were using a helper which incorrectly escaped invalid URI characters with lower case hex value. i.e. `%3d`. Then proper form would be uppercase -> `%3D` - Discussion https://stackoverflow.com/a/48301702/18174950 - https://stackoverflow.com/a/47877559/18174950 - https://edi.wang/post/2018/11/25/netcore-webutility-urlencode-httputility-urlencode - https://stackoverflow.com/a/51829522/18174950 ## How was this tested? - [x] Integration Tests- updated existing integration tests. - [ ] Unit Tests ## Sample Request(s) - Using the configuration/SQL db script provided in the issue, the following request will succeed now and provide a valid NextLink: `https://localhost:5001/api/todo?$orderby=title desc, tid asc`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why make this change?
What is this change?
TryResolveJsonElementToScalarVariable(element.GetProperty(column)TryResolveJsonElementToScalarVariable(element.GetProperty(exposedColumnName)Issue when loading request "FindMany" within pagination token
With a request like
GET https://localhost:5001/api/todoThis result is returned as next link:
NameValueCollectionwhich contains all query string key/value pairs was not being resolved into a query string and the nextLink looked like:"nextLink": "https://localhost:5001/api/todo/System.Collections.Specialized.NameValueCollection"%3d. Then proper form would be uppercase ->%3DHow was this tested?
Sample Request(s)
https://localhost:5001/api/todo?$orderby=title desc, tid asc