Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Null SQL values can be generated from the Haversine implementation, instead of the expected 0 (zero) value, e.g., when the origin/destination have the same exact Lat/Lng values.
Proposed resolution
We can work around the issue by using IFNULL( ..., 0) and get the expected 0 value.
Comment | File | Size | Author |
---|---|---|---|
#2 | null_sql_result_with-2761811-2.patch | 1.28 KB | jtwalters |
Comments
Comment #2
jtwalters CreditAttribution: jtwalters commentedHere's a patch that provides the IFNULL( ..., 0) change to ensure a zero value is returned when the origin/destination are exactly the same.
Comment #3
jtwalters CreditAttribution: jtwalters commentedComment #4
jtwalters CreditAttribution: jtwalters commentedActually, IFNULL isn't ideal, since it'll result in a value of "0" where geofield data does not exist on content. A better solution seems to be LEAST(1, ...) which I can attach a patch for.