I have locative information enabled for a certain node type, and user locations enabled as well. When I try to use gmap or list view to list this certain type of node it duplicated one of the nodes.

I traced the problem to the views_build_view function, where an incorrect query is executed:

SELECT node.nid, node.created AS node_created_created, node.title AS node_title, node.changed AS node_changed, location.latitude AS location_latitude, location.longitude AS location_longitude FROM shared_node node LEFT JOIN shared_location location ON node.vid = location.eid WHERE ( (node.status = '1') AND (node.type IN ('airport')) ) ORDER BY node_created_created DESC;

If you have a table where 'eid' is not unique in location (which can happen for example if you have locative information for node 1 and user 1, eid will be 1 for both of them) this selects both. As a result node 1 will show up twice, first with its original data, second inheriting the locative information of user 1.

The correct query would be:
SELECT node.nid, node.created AS node_created_created, node.title AS node_title, node.changed AS node_changed, location.latitude AS location_latitude, location.longitude AS location_longitude FROM shared_node node LEFT JOIN shared_location location ON node.vid = location.eid WHERE ( (node.status = '1') AND (location.type = 'node') AND (node.type IN ('airport')) ) ORDER BY node_created_created DESC;

I inserted an AND (location.type = 'node') into the query.

Comments

merlinofchaos’s picture

Project: Views (for Drupal 7) » Location Views
Version: 5.x-1.6-beta5 »

Sounds like Location's Views integration's problem to me.

matt2000’s picture

Status: Active » Needs review

I couldn't quickly find a way to automatically filter out the user records, but adding this filter lets you set it in the View settings.

In location_views.module, add this element to the 'filters' array:


'type' => array(
'field' => 'type',
'name' => t('Location: Type'),
'help' => t('Set to \'node\' to avoid problems.'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
),

In my copy, this was added at line 92. It's in the function location_views_tables(). The full hierarchy for the above element would be: $table['location']['filters']['type'] .