-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Fix for GeoJSON
output erroneously producing an Array for the postalcode
field.
#1684
Conversation
Worth noting an oddity I found... The We correctly favour However we end up merging in the So what we end up is a sort of mishmash of the two: postalcode_a: 'parent postalcode_a value',
postalcode_gid: 'parent postalcode_id value',
postalcode_source: 'parent postalcode_source value',
postalcode: 'zip value', |
function setup() { | ||
return renamePlacenames; | ||
return mapFields; | ||
} | ||
|
||
function renamePlacenames(req, res, next) { | ||
function mapFields(req, res, next) { | ||
// do nothing if no result data set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, much better naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to update all the references 😢
Just pushed rebase to resolve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oof. And no tests caught it !? I thought we'd have so many tests that can't happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, because it was in routes
which isn't tested.
89ce1a8
to
4bd67dd
Compare
This PR fixes an issue with the
GeoJSON
output which is erroneously producing an Array for thepostalcode
field for some records (ie. only those with aliases)This was a tricky bug to track down, it's a combination of this cast which has been around for 9 years combined with some more modern work which triggered it.
We have some logic to 'flatten' array values to strings in the API codebase (
helper/fieldValue.js
), but what's happening here is that the Array coming back from elasticsearch is being wrapped in a second array,getStringValue()
only flattens a single level.The rest of this PR is me adding tests to try and understand what
middleware/renamePlacenames
did, and then renaming it to make it clearer what exactly it does 🤷https://pelias.github.io/compare/#/v1/search?text=kinkerstraat+175F