I'm setting up a view using a relationship with the flag module. The goal is to create a view of nodes that a specific user flagged.

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /admin/structure/views/ajax/preview/user_likes
StatusText: Service unavailable (with message)
ResponseText: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'uid' in on clause is ambiguous: SELECT COUNT(*) AS expression
FROM
(SELECT node.title AS node_title, node.nid AS nid, 1 AS expression
FROM
{node} node
LEFT JOIN {users} users_flag_content ON uid = users_flag_content.uid
WHERE (( (node.status <> :db_condition_placeholder_0) AND (users_flag_content.uid = :db_condition_placeholder_1) ))) subquery; Array
(
[:db_condition_placeholder_0] => 0
[:db_condition_placeholder_1] => 1
)
in views_plugin_pager->execute_count_query() (line 141 of /.../sites/all/modules/contrib/views/plugins/views_plugin_pager.inc).

The left join here "LEFT JOIN {users} users_flag_content ON uid = users_flag_content.uid" doesn't use node.uid as it should.

Any ideas?
- Scott

Comments

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Can you please export the view?

In general this looks like a problem of the flag module in d7.

hadsie’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new4.19 KB

Yeah, it's quite possible it's an issue with flags. I wasn't sure though... the view is attached...

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Can you please provide a flag export, too?

To be able to fix this bug it's required to reproduce the bug :)
Alternative a feature (from the features module) is required.

hadsie’s picture

StatusFileSize
new760 bytes
new1.51 KB

Of course, sorry :). Here's a feature with the view and the flag, and also the flag export by itself (just for good measure).

hadsie’s picture

Status: Postponed (maintainer needs more info) » Active

Any ideas on whether this is a views or a flag issue?

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Can you test whether this still happens with the latest version of views (dev) ?

There was a lot of fixes recently.

hadsie’s picture

Status: Postponed (maintainer needs more info) » Active

Updated to the latest versions of Drupal, Views, and Flag and I'm still getting the exact same error message :/.

Where you not able to reproduce the issue with the attached code?

Thanks!
Scott

iamjon’s picture

Status: Active » Postponed (maintainer needs more info)

hadsie,
I installed your feature, what do I have to do to replicate the error? Please provide step by step instructions.

palik’s picture

subscribing,

I think I have similar issue.

1) I created a new type of content - an meeting,
2) I created a a flag "i'll be there" so an user can confirm that he/she will be attending,
3) I created a view "who flagged a node", with relationship between nodes and users, with id of node as argument,
4) When I add "user name" and "user email" - everything works perfect - I get names and mails of users who flagged a meeting.
5) when I add "bio" or any other field that I created in users - I receive 0 results. Sometimes I receive an strange error - nearly a blank page with whole view definition in one very long line.

dawehner’s picture

The replication is really the main thing here. Without a reproducable bug it's impossible to fix this, perhaps, existing bug.

Here it would also help if you could enable display of php errors

hadsie’s picture

Status: Postponed (maintainer needs more info) » Fixed

Ok, I've been able to resolve the issue here. I believe it was ultimately an issue with the flag module, it let me select the "flag: user" relationship without selecting the necessary 'Flags: flag_name' relationship as well. The module seems to not allow that anymore and I can build the view with no errors. Thanks for your guys' time in looking into this one!!

- Scott

Status: Fixed » Closed (fixed)

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

mstef’s picture

Title: uid in on clause is ambiguous -- error when adding a relationship » Integrity constraint violation: 1052 Column 'uid' in field list is ambiguous
Status: Closed (fixed) » Active
StatusFileSize
new4.88 KB

Getting this with the latest dev on a comment view using relationship comment:content and comment:user.

Error message: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'uid' in field list is ambiguous

See attached view

mstef’s picture

Pretty obvious problem in the query:

SELECT users_comment.name AS users_comment_name, users_comment.uid AS users_comment_uid, comment.created AS comment_created, node_comment.title AS node_comment_title, node_comment.nid AS node_comment_nid, picture AS picture, uid AS uid, name AS name, mail AS mail
FROM 
{comment} comment
INNER JOIN {users} users_comment ON comment.uid = users_comment.uid
INNER JOIN {node} node_comment ON comment.nid = node_comment.nid
WHERE (( (comment.status <> '0') AND (node_comment.status = '1') ))
ORDER BY comment_created DESC
LIMIT 10 OFFSET 0
merlinofchaos’s picture

While I don't know why this happened, the problem is here:

/* Field: User: Picture */
$handler->display->display_options['fields']['picture']['id'] = 'picture';
$handler->display->display_options['fields']['picture']['table'] = 'users';
$handler->display->display_options['fields']['picture']['field'] = 'picture';

That field does not have a relationship, meaning it's trying to work from the base relationship. It *should* be auto-adjusting to use the user relationship, but maybe somehow that's failing. Edit the view, edit that field, and ensure it's selecting the correct relationship. Then choose 'update' on that field (Regardless of whether it appeared to have the correct value or not) and try previewing the view to see if the query is updated.

If that doesn't, check all of the user: fields for the same thing.

mstef’s picture

Status: Active » Closed (fixed)

Ah.. that did work. Good call. I wonder why the relationship wasn't automatically selected (like the other fields were).

Thanks

merlinofchaos’s picture

Status: Closed (fixed) » Active

That part seems like it is still a bug and should be explored.

For example, can you create a new view similarly and still have this problem?

mstef’s picture

hm.. can't seem to get it to happen again.

fietserwin’s picture

Issue summary: View changes

Seems like a duplicate of #1309142: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'vid' in field list is ambiguous (or the other way around, but that issue is more generic and has more information)?