There is a linked entity id field in user points transactions table which references the entity of the transaction (ie; node id). When I try to add that relationship in views I get the following warning:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'userpoints_txn.nid' in 'on clause'

You can also see from the query below it is trying to find nid rather than entity id.

SELECT userpoints_txn.points AS userpoints_txn_points
FROM
{userpoints_txn} userpoints_txn
INNER JOIN {node} node_userpoints_txn ON userpoints_txn.nid = node_userpoints_txn.nid

Any suggestion? This is a view based on user points transactions and trying to link a node relationship. I will try a node view and link the transaction relationship.

CommentFileSizeAuthor
#3 cant_relate_to_node-1668498-3-D7.patch609 bytesdimilias

Comments

IWasBornToWin’s picture

Just tried view other way around (node view with linked user point.). No option available.

holtzermann17’s picture

I also have this issue on 7.x-1.0.

Modifying the 'field' on line 430 of userpoints.views.inc from 'nid' to 'entity_id', like so...

      'relationship' => array(
          'base' => 'node',
          'field' => 'entity_id',
          'label' => t('Entity'),
          'handler' => 'views_handler_relationship',
      ),

... gives me some results -- but for some reason it only seems to work for adding content, not for revisions or deletions. Also, with 'base' => 'node' hardcoded in there, I question whether this will work for points associated with other kinds of entities.



I get this warning, which I think is associated with the revisions (for which no node-related info is showing up).

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /home/joe/switch/drupal_planetary/includes/entity.inc).

There are some relevant comments about setting up a "variable base" here: http://drupal.org/node/1748480

dimilias’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Issue summary: View changes
StatusFileSize
new609 bytes

I am changing this to 7.x-1.x as I have turned the answer from comment #2 into a patch. Don't know if it applies in 7.x-2.x but this is also an issue in 7.x-1.x. It can be ported for the newest dev.