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
"url" field is undefined when restricting returned fields via the API #6625
Comments
Hi @jaswilli, thanks for taking a look at this! Seeing as you committed yesterday, I take it that if I install the latest master I should be able to finish up testing and close the issue? Thanks |
I'm reopening this as I've just spotted it is not fixed / has regressed. E.g: adding
|
I am not able to reproduce this bug on current master. I've tested with postman and test-wise. |
I reproduced the two bugs on latest master by grabbing the access token and making a get request with the browser like:
Bug 1: The above request results in all fields still being returned, the
Bug 2: the above request results in only the 2 fields specified being returned, but the URL is always |
|
closes #6625 - "url" and "author" fields depend on {id, published_at, slug, author_id} to construct post url. - implemented a generic solution by defining defaultColumnsToFetch() in base class for models. - findPage() calls defaultColumnsToFetch() before loading models - results are transformed by filtering out additional properties to return just the requested fields - Added a test case to check for url and author fields - Renamed allColumns as requestedColumns and used _.map instead of Promise.map
…ost#7089) closes TryGhost#6625 - "url" and "author" fields depend on {id, published_at, slug, author_id} to construct post url. - implemented a generic solution by defining defaultColumnsToFetch() in base class for models. - findPage() calls defaultColumnsToFetch() before loading models - results are transformed by filtering out additional properties to return just the requested fields - Added a test case to check for url and author fields - Renamed allColumns as requestedColumns and used _.map instead of Promise.map
Closes TryGhost#6625 - Adds a failing test for not returning computed columns as well as for the bookshelf bug where extra columns passed into a fetch will result in the model having an extra "quoted" column. - Filter model attributes for passing into "fetch" but used the entire list of columns for `toJSON`.
…ost#7089) closes TryGhost#6625 - "url" and "author" fields depend on {id, published_at, slug, author_id} to construct post url. - implemented a generic solution by defining defaultColumnsToFetch() in base class for models. - findPage() calls defaultColumnsToFetch() before loading models - results are transformed by filtering out additional properties to return just the requested fields - Added a test case to check for url and author fields - Renamed allColumns as requestedColumns and used _.map instead of Promise.map
Issue Summary
When querying a posts list with the API, the "url" field returns "undefined" if the fields to be returned have been specified.
Interestingly, if one wants to construct a full list of post urls with no further information, a list of all fields except the url is returned.
Steps to Reproduce
This first query returns a list of all posts with all their fields.
The following query, which should return exactly the same thing, returns all fields except "url" and "author".
The "author" can be added by using "include: "author", so this may be a feature and not a bug.
Using the syntax author_id also returns the expected result.
To test what happens if a list of URLs needs to be generated, the following query can be used :
Technical details:
The text was updated successfully, but these errors were encountered: