after updating to 2.5 (from old 2.x) i get sql error because of empty uid fields when using content profile relationship + cck userreference relationship

add a reationship: content -> userreference relationship 'member_ref'
add another relationship node -> content profile -> use relationship (yes): 'member_ref'

Comments

merlinofchaos’s picture

I suppose I'm supposed to guess what error you got? Or just magically know?

gunzip’s picture

against current (and older) content profile:


    * 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 '= node_users.uid AND node_users.type = 'profilo_assistenza' LEFT JOIN content_t' at line 5 query: SELECT COUNT(*) FROM (SELECT DISTINCT(node.nid) AS nid FROM node node LEFT JOIN content_type_richiesta node_data_field_utente_assegnato ON node.vid = node_data_field_utente_assegnato.vid LEFT JOIN users users_node_data_field_utente_assegnato ON node_data_field_utente_assegnato.field_utente_assegnato_uid = users_node_data_field_utente_assegnato.uid LEFT JOIN node node_users ON .uid = node_users.uid AND node_users.type = 'profilo_assistenza' LEFT JOIN content_type_profilo_assistenza node_data_field_nominativo ON node_users.vid = node_data_field_nominativo.vid ) count_alias in ../views/includes/view.inc on line 705.

    * 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 '= node_users.uid AND node_users.type = 'profilo_assistenza' LEFT JOIN content_t' at line 9 query: SELECT DISTINCT(node.nid) AS nid, node_data_field_nominativo.field_nominativo_value AS node_data_field_nominativo_field_nominativo_value, node_users.nid AS node_users_nid, node_users.type AS node_users_type, node_users.vid AS node_users_vid FROM node node LEFT JOIN content_type_richiesta node_data_field_utente_assegnato ON node.vid = node_data_field_utente_assegnato.vid LEFT JOIN users users_node_data_field_utente_assegnato ON node_data_field_utente_assegnato.field_utente_assegnato_uid = users_node_data_field_utente_assegnato.uid LEFT JOIN node node_users ON .uid = node_users.uid AND node_users.type = 'profilo_assistenza' LEFT JOIN content_type_profilo_assistenza node_data_field_nominativo ON node_users.vid = node_data_field_nominativo.vid LIMIT 0, 15 in ../views/includes/view.inc on line 731.

.. ON .uid = node_users.uid ... has an empty table.

view follows. (as you can see the chain is: content profile field -> content profile relationship -> userref relationship)

$view = new view;
$view->name = 'richieste_per_supervisore';
$view->description = 'Richieste per il supervisore';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'field_utente_assegnato_uid' => array(
    'label' => 'Member',
    'required' => 0,
    'delta' => -1,
    'id' => 'field_utente_assegnato_uid',
    'table' => 'node_data_field_utente_assegnato',
    'field' => 'field_utente_assegnato_uid',
    'relationship' => 'none',
  ),
  'content_profile_rel' => array(
    'label' => 'Member profile',
    'required' => 0,
    'type' => 'profilo_assistenza',
    'id' => 'content_profile_rel',
    'table' => 'users',
    'field' => 'content_profile_rel',
    'override' => array(
      'button' => 'Sovrascrivi',
    ),
    'relationship' => 'field_utente_assegnato_uid',
  ),
));
$handler->override_option('fields', array(
  'field_nominativo_value' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_nominativo_value',
    'table' => 'node_data_field_nominativo',
    'field' => 'field_nominativo_value',
    'override' => array(
      'button' => 'Sovrascrivi',
    ),
    'relationship' => 'content_profile_rel',
  ),
));
$handler->override_option('access', array(
  'type' => 'role',
  'role' => array(
    '3' => 3,
  ),
));
$handler->override_option('title', 'Richieste (tutte)');
$handler->override_option('empty', 'Nessuna richiesta.');
$handler->override_option('empty_format', '1');
$handler->override_option('items_per_page', 15);
$handler->override_option('use_pager', '1');
$handler->override_option('style_options', array(
  'grouping' => '',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'richieste-supervisore');
$handler->override_option('menu', array(
  'type' => 'normal',
  'title' => 'Richieste (tutte)',
  'description' => 'Richieste (tutte)',
  'weight' => '-10',
  'name' => 'menu-menu-supervisore',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
alexking’s picture

Having this same problem -

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 '= node_users.uid AND node_users.type = 'profile' WHERE (user_relationships.appr' at line 8 query: 
execute /* admin : execute */ SELECT user_relationships.rid AS rid, users_user_relationships.name AS users_user_relationships_name, users_user_relationships.uid AS users_user_relationships_uid FROM user_relationships user_relationships LEFT JOIN users users_user_relationships ON user_relationships.requestee_id = users_user_relationships.uid LEFT JOIN users users_user_relationships_1 ON user_relationships.requester_id = users_user_relationships_1.uid LEFT JOIN user_relationship_types user_relationship_types_user_relationships ON user_relationships.rtid = user_relationship_types_user_relationships.rtid LEFT JOIN node node_users ON .uid = node_users.uid AND node_users.type = 'profile' WHERE (user_relationships.approved = '1') AND (user_relationships.requester_id = 1) LIMIT 0, 30
loze’s picture

Same problem here

.. ON .uid = node_users.uid ... has an empty table.

Junro’s picture

Subscribe, came back to 2.3 version.

gunzip’s picture

Title: views 2.5 broke content profile relationships » views 2.5 sql error "ON .uid = node_users.uid" ... has empty table.

better title

related to http://drupal.org/node/437960

rjbrown99’s picture

I have been bashing my head into a wall for two days trying to figure out why I could not implement a user relationship view that also included a reference to the requestee's content profile. Guess what? This was the problem. The fix from post #4 on the other duplicate thread was the answer.

This is the comment that specifically fixed my query:
http://drupal.org/node/437960#comment-1513360

gunzip’s picture

dww’s picture