Stale coordinates after lookup fail
Closed this issue · 1 comments
Please close this issue if this is expected behaviour, I've searched the docs for specifications regarding failed lookups and found nothing.
Expected behaviour
After geocoding lookup fails, coordinates should be reset to nil
and geocoded?
should return false
.
Actual behaviour
Currently, if you change the address but the subsequent lookup fails, the older, stale, coordinates remains saved and geocoded?
returns true
.
Steps to reproduce
I see this as fairly
Environment info
- Geocoder version: 1.6
- Rails version: Rails 6.1
- Database (if applicable): PostgreSQL
- Lookup (if applicable): Nominatim
I'd be happy to provide a PR clarifying this on the README and/or code satisfying expected behaviour.
So, this is the expected behavior. The reason is that it can be hard to distinguish between a failed lookup that represents a temporary issue with an API (which you'd want to ignore) and a failed lookup that means an address is invalid or can't be geocoded (which you'd want to save).
The good news is that you can override this behavior in your geocoded model by doing the geocoding in a block, as described in the README.
Hope that helps.