alexreisner/geocoder — Issue #194: add_exclude_condition breaks on tables without ID field
Author: alexgandy
Created: 2012-03-06 20:52:15+00:00
State: open

I'm working with a legacy database with a primary key column named "place_id" instead of "id". Similarly the latitude and longitude fields are named "place_latitude" and "place_longitude", but I've specified those fields in the geocoder options.

The "nearbys" function generates the following query:

SELECT place.*, 3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((39.28127 - place.place_latitude) * PI() / 180 / 2), 2) + COS(39.28127 * PI() / 180) * COS(place.place_latitude * PI() / 180) * POWER(SIN((-76.59474290000003 - place.place_longitude) * PI() / 180 / 2), 2) )) AS distance, CAST(DEGREES(ATAN2( RADIANS(place_longitude - -76.59474290000003), RADIANS(place_latitude - 39.28127))) + 360 AS decimal) % 360 AS bearing FROM `place` WHERE (3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((39.28127 - place.place_latitude) * PI() / 180 / 2), 2) + COS(39.28127 * PI() / 180) * COS(place.place_latitude * PI() / 180) * POWER(SIN((-76.59474290000003 - place.place_longitude) * PI() / 180 / 2), 2) )) <= 10 AND place.id != 3374) ORDER BY distance

The hardcoded "place.id" field appended by the add_exclude_condition breaks the query. Is there a way to stop the exclude condition from being added to the query? Or can you set the ID field, similar to the latitude/longitude options?