// $Id: location.module,v 1.79.2.12 2007/08/23 01:09:16 ankur Exp $
I get the following error msg:
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT(n.nid)) AS count FROM node n INNER JOIN location l ON n.vid = l.eid WHE' at line 1 query: location_search_results SELECT COUNT(DISTINCT DISTINCT(n.nid)) AS count FROM node n INNER JOIN location l ON n.vid = l.eid WHERE l.type ='node' AND l.latitude > 45.1202970241 AND l.latitude < 45.8443849759 AND l.longitude > -123.116446354 AND l.longitude < -122.083693646 AND (IFNULL(ACOS(0.701129060281*COS(RADIANS(latitude))*(-0.538771814256*COS(RADIANS(longitude)) + -0.842451738774*SIN(RADIANS(longitude))) + 0.713034389654*SIN(RADIANS(latitude))), 0.00000)*6367237.71671) < 40233.68 in /home/sean/svn/clients/csp/main/trunk/drupal/includes/database.mysql.inc on line 172.
The error is caused by the "DISTINCT DISTINCT". I can get rid of the error if I I remove "DISTINCT" from location.module line 185 as follows:
Was:
$count_query = 'SELECT COUNT(DISTINCT nid) AS count FROM {node} n INNER JOIN {location} l ON n.vid = l.eid WHERE l.type =\'node\' AND l.latitude > %f AND l.latitude < %f AND l.longitude > %f AND l.longitude < %f AND '. earth_distance_sql($latlon['lon'], $latlon['lat']) .' < %f';
Now:
$count_query = 'SELECT COUNT(nid) AS count FROM {node} n INNER JOIN {location} l ON n.vid = l.eid WHERE l.type =\'node\' AND l.latitude > %f AND l.latitude < %f AND l.longitude > %f AND l.longitude < %f AND '. earth_distance_sql($latlon['lon'], $latlon['lat']) .' < %f';
I'm guessing that some other module is hooking into this search function and adding the second distinct. Or many I've got some issue with my configuration.
I'm running Drupal 5.3 with the latest dev releases of gmaps and locations. I haven't been able to repeat this issue on other installations in Drupal 5.2 or 5.3. And I'm running Mysql 5 and PHP 5.2.
I'm using node revisions and I'm not getting any duplicate nodes listed in my search results, so I'm guessing I'll just go with this patch. I'm curious if anyone else has encountered this issue.
Thanks,
sean
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | location_16.patch | 1.14 KB | seanberto |
Comments
Comment #1
ankur commentedHey Sean,
Thanks for the tip. This has been fixed in the DRUPAL-5 branch.
-Ankur
Comment #2
seanberto commentedI haven't dived too deep into how this module works, but I found a curious bug after upgrading to the latest version. For some reason, the lastest version throws an SQL error for unauthenticated users - but not authenticated users.
The attached patch solves the problem.
Comment #3
seanberto commentedSorry, ran diff incorrectly. ;)
You need the n.nid, not just nid in the select statement.
Comment #4
mlncn commentedSubscribing.
Comment #5
ankur commentedCampsoupster, you're absolutely right. This problem should be fixed now in CVS.
-Ankur
Comment #6
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.