The geo_data views handler adds an extra alias to the last field of the internal fields (srid, wkb, bbox, centroid) returned by geo('field_select', ... ) when it uses $this->query->add_field().
See line 9 of the following SQL written by Views/views_handler_field_geo_data:
1 SELECT node.nid AS nid,
2 node.title AS node_title,
3 node.uid AS node_uid,
4 node.type AS node_type,
5 node_revisions.format AS node_revisions_format,
6 SRID(geo) as geo_srid,
7 AsBinary(geo) AS geo_wkb,
8 AsBinary(Envelope(geo)) AS geo_bbox,
9 AsBinary(Centroid(geo)) AS geo_centroid AS node_data_field_area_field_area_value,
10 node_data_field_area_geo.label AS node_data_field_area_geo_label,
11 node_data_field_area_geo.id AS node_data_field_area_geo_id
12 FROM node node
13 LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid
14 LEFT JOIN content_field_area node_data_field_area ON node.vid = node_data_field_area.vid
15 LEFT JOIN geo_data_ssw_regions node_data_field_area_geo ON node_data_field_area.field_area_value = node_data_field_area_geo.id
16 WHERE node.type in ('organization')
17 GROUP BY nid, node_title, node_uid, node_type, node_revisions_format, node_data_field_area_geo_label, node_data_field_area_geo_id
The attached patch removes the alias from the add_field() method call, and fixes a typo in geo_field_select().
Comments
Comment #1
becw commentedActually, the
geo('field_select', 'field_name')call needs to be handed the table alias as part of the field name--so that you can select data from multiple geo tables, and so that the geodata is available in predictably named places in the render() function. See the attached patch (which should replace the previous patch).Comment #2
apolzon commentedThanks! I can confirm that this fixes the sql bug in views with geo. (Applied to 6.x-1.0-alpha1)
Comment #3
allie mickaCommitted.
Thanks bec and apolzon!