This issue is part of meta issue #1931088: [META] Fixing tests

This might be an issue for the Views issue queue, but I'm not really familiar enough with the issue to make that call.

Adding a relationship to a CCK Location field in Views 3.x generates the following error:

user warning: Unknown column 'node_data_field_location.lid' in 'on clause' query: SELECT DISTINCT location_node_data_field_location.lid AS location_node_data_field_location_lid FROM node node LEFT JOIN content_type_company node_data_field_location ON node.vid = node_data_field_location.vid LEFT JOIN location location_node_data_field_location ON node_data_field_location.lid = location_node_data_field_location.lid in /home/quickstart/websites/example.com/public_html/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 1153.

Details:
CCK field is `field_location`
content type is `company`

I've tried to simplify the view as much as possible to shorted the SQL query and identify the issue. I'll continue and troubleshoot and add details. In the meantime, if anyone has a word of advice on the issue, any help would be appreciated.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

grasmash’s picture

Project: Views (for Drupal 7) » Location
Issue summary: View changes

changing filepath

dawehner’s picture

Component: Miscellaneous » Code

That's probably a location module issue.

ayalon’s picture

I have the same problem!
I updated to the latest views. The error occurs since the update.

emosbaugh’s picture

same issue here

emosbaugh’s picture

Issue summary: View changes

wrapping in code tags

ayalon’s picture

I removed all Relationships with Location and added the fields without a relationship. This solved the problem.

grasmash’s picture

@ayalon: That only works if you're only using a single CCK field.

If you're using two location CCK fields for different purposes, there is no way to specify which one the view should use for locational information. That presents a problem for any instance in which the Location CCK field needs to be specified, e.g, filters, sort criteria, arguments, or fields.

grasmash’s picture

Issue summary: View changes

edit

pthornhi6’s picture

Ok... I have this problem too.. I have it loading again. However, not in a way that will work systemically. I do want, however, to share what I have done just in case it helps.

I added the column lid to the content_field_location table. Then set the values in that column equal to the values in the lid column. Now everything is working again. I just can't do it this way because I don't believe the system will keep my column up to date.

cossme’s picture

Hi there,

I was having the same problem (using views-6.x.-3.0-rc1 and location-6.x.-3.x-dev Version of November 4th). As I understand this is caused by the location module not providing views with the correct information for the join defintions due to some changes in the views api.

Because my knowledge of the (updated) views api and the location module itself is rather poor I used a more or less quick and dirty hack to correct it (needed a solution fast). I used hook_views_query_alter to adjust the join definition for the location tables. In code this looks soemthing like this:

function MYMODULDE_views_query_alter(&$view, &$query) {
  if (!empty($query->table_queue['location_node_data_MYFIELD_NAME']['join']->left_field)) {
    $query->table_queue['location_node_data_MYFIELD_NAME']['join']->definition['left_field'] = 
    $query->table_queue['location_node_data_MYFIELD_NAME']['join']->left_field =
      'MYFIELD_NAME_lid';
  }
}

Not really beautiful but it works for now for me.

Cheers,
cossme

arcaneadam’s picture

Status: Active » Needs review
FileSize
630 bytes

This patch should fix the issue. In the CCK definition it was telling views to use lid as the field as opposed to the field_alias

mattcasey’s picture

#8 works for me, using Location 3.x-dev and Views 3.0-rc2

AaronBauman’s picture

Status: Needs review » Reviewed & tested by the community

thank you, arcaneadam - so glad i didn't have to track this down myself.
#8 works for me, and it's a one-liner of a very obvious bug - let's get it in!

ankur’s picture

Does this patch break compatibility with 6.x-2.x?

If so, I'd like to figure out the best way to maintain compatibility with both views 6.x-2.x and views 6.x-3.x before committing this patch to location's 6.x-3.x branch.

arcaneadam’s picture

I don't think this is an issue with views. It's an issue more with how Location and CCk define the field with views. All it does is ensure that the DB field views is querying against is the correct field.

That being said. I agree it would be a good idea for someone to test vs. views 2 to ensure it still works.

ayalon’s picture

The patch works flawlessly and should be commited soon. Using Views 3 is very common now.

Don't forget to flush the cache, because views schemas are cached.

GiorgosK’s picture

The patch works great with views 3
please commit

fehin’s picture

#8 patch worked for me too. Is there a reason it hasn't been committed yet?

djdevin’s picture

Works here as well. If there was a step higher than RTBC I'd mark it.

DarrellDuane’s picture

RE #11, I hate to say it, but perhaps we need to make two versions of the Location module, one for views 2 and one for views 3 and create warning messages if they're out of sync.

#8 works for me with views-6.x-3.x

podarok’s picture

Status: Reviewed & tested by the community » Postponed

postponed before tests fix
#1931088: [META] Fixing tests

podarok’s picture

postponed before tests fix
#1931088: [META] Fixing tests

podarok’s picture

Issue summary: View changes

removed redundant link

podarok’s picture

Status: Postponed » Needs review

tests fixed #1931088: [META] Fixing tests
lets go

podarok’s picture

Status: Needs review » Fixed

#8 commited pushed to 6.x-3.x
thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.