Hi. Lately I found a long sheet of error reports on every user profile on my site:

user warning: Unknown column 'user_relationships.uid' in 'on clause' query: SELECT COUNT(*) FROM (SELECT users_user_relationships.name AS users_user_relationships_name, users_user_relationships.uid AS users_user_relationships_uid, users_user_relationships.picture AS users_user_relationships_picture, users_user_relationships.mail AS users_user_relationships_mail, user_relationship_types_user_relationships.plural_name AS user_relationship_types_user_relationships_plural_name FROM user_relationships user_relationships LEFT JOIN users users_user_relationships ON user_relationships.uid = users_user_relationships.uid LEFT JOIN users users_user_relationships_1 ON user_relationships.uid = 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 WHERE (user_relationships.approved = '1') AND (user_relationships.requester_id = 1 ) ) count_alias in ..../sites/all/modules/views/plugins/views_plugin_pager.inc on line 141.
user warning: Unknown column 'user_relationships.uid' in 'on clause' query: SELECT users_user_relationships.name AS users_user_relationships_name, users_user_relationships.uid AS users_user_relationships_uid, users_user_relationships.picture AS users_user_relationships_picture, users_user_relationships.mail AS users_user_relationships_mail, user_relationship_types_user_relationships.plural_name AS user_relationship_types_user_relationships_plural_name FROM user_relationships user_relationships LEFT JOIN users users_user_relationships ON user_relationships.uid = users_user_relationships.uid LEFT JOIN users users_user_relationships_1 ON user_relationships.uid = 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 WHERE (user_relationships.approved = '1') AND (user_relationships.requester_id = 1 ) ORDER BY user_relationship_types_user_relationships_plural_name ASC LIMIT 0, 12 in ..../sites/all/modules/views/plugins/views_plugin_query_default.inc on line 1150.

I wonder this bug is on User Relationships side or on a new version of Views (3.x)? User Relationships incompatible with Views 3.x or should I report about this on a Views bug tracking?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mrf’s picture

Well it looks like views 3 on Drupal 6 has over 8k users despite it being in alpha so we'll have to put it on the testing list for sure.

If you can provide more information about which UR views you have enabled when these errors were triggered that would be helpful.

STINGER_LP’s picture

That's the question... None of it, all UR views terned off.

mrf’s picture

Issue tags: +6.x-1.1

The plot thickens, I'll try to take a look at this one soon. Tagging for a closer look.

MasterChief’s picture

I have the same bug, and it was working before, i am using views 3.x too.

inky@inky3d.com’s picture

I've also got the same issue - recently upgraded to views 3 on the dev version of a site, and now get the same error. Am using UR 6.x-1.0

I've not enabled any of the default UR views, but the error appears on a custom view I built listing all relationships, and some views that were generated by Advanced Profile Kit on the profile panel.

I can test with the default UR views, if you need?

mrf’s picture

Component: Code » Views

Are you using 6.x-3.x-dev or 6.x-3.0-alpha of views? I didn't get errors with the two default views on the alpha.

Any chance you can attach an export of the problematic views?

inky@inky3d.com’s picture

ah ok, yeah - it was 6.x-3.x-dev that was causing the issues.

6.x-3.0-alpha seems to play nicely - thanks!

Edit: Although reverting back has lost me a whole lot of styling :(

inky@inky3d.com’s picture

FileSize
9.67 KB

I had to admit defeat and go back to using 6.x-3.x-dev - too much of my site broke by reverting to the alpha.

Attached is an export of the view that results in this error:

user warning: Unknown column 'user_relationships.uid' in 'on clause' query: SELECT COUNT(*) FROM (SELECT user_relationships.approved AS user_relationships_approved, users_user_relationships_1.name AS users_user_relationships_1_name, users_user_relationships_1.uid AS users_user_relationships_1_uid, users_user_relationships.name AS users_user_relationships_name, users_user_relationships.uid AS users_user_relationships_uid, user_relationships.updated_at AS user_relationships_updated_at FROM user_relationships user_relationships LEFT JOIN users users_user_relationships ON user_relationships.uid = users_user_relationships.uid LEFT JOIN users users_user_relationships_1 ON user_relationships.uid = users_user_relationships_1.uid WHERE user_relationships.approved = '0' ) count_alias in /home/inkydcom/public_html/tickmarkers/sites/all/modules/views/plugins/views_plugin_pager.inc on line 141.
user warning: Unknown column 'user_relationships.uid' in 'on clause' query: SELECT user_relationships.approved AS user_relationships_approved, users_user_relationships_1.name AS users_user_relationships_1_name, users_user_relationships_1.uid AS users_user_relationships_1_uid, users_user_relationships.name AS users_user_relationships_name, users_user_relationships.uid AS users_user_relationships_uid, user_relationships.updated_at AS user_relationships_updated_at FROM user_relationships user_relationships LEFT JOIN users users_user_relationships ON user_relationships.uid = users_user_relationships.uid LEFT JOIN users users_user_relationships_1 ON user_relationships.uid = users_user_relationships_1.uid WHERE user_relationships.approved = '0' LIMIT 0, 10 in /home/inkydcom/public_html/tickmarkers/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 1150.

iRex’s picture

subscribing

jimijamesi’s picture

This also happens for us... user warning: Unknown column 'user_relationships.uid' ...etc.
using 6.x-3.x-dev version of views
basic views incl. in user-relationships work fine

my custom view breaks as soon as I add a value(displayed below) in the Relationships section (of the view build UI)
User relationships: Requestee user
(requestee) Node: Content Profile

each of the above Relationship values will cause an error to start appearing but the
user warning: Unknown column 'user_relationships.uid' is caused by the -> User relationships: Requestee user

let me know if you want an export of the view or more details.

edit: I was able to get my custom view working by regressing to views6.3alpha3 - however this is a year old and it may or may not work for some other functionality (apache solr map results)... I would much rather use views 6.3.x-dev (which is the latest nightly build)

mrf’s picture

<mrf> Is there any documentation or best practices in making 6.x-2.x views integration code work with the 6.x-3.x branch? Apparently a lot of users are already running on it.
<merlinofchaos> mrf: The documentation on doing that is limited. On the plus side, 95% of views integration isn't affected.
<merlinofchaos> mrf: You run into problems with little things like: 1) you can't assume the primary key of a base table is in the query anymore 2) paging has changed 3) exposed forms are more than just filters
<merlinofchaos> mrf: 4) styles got a lot more flexibility so sometimes that causes little changes.
<merlinofchaos> mrf: But something like 80% of the time hook_views_data() won't need any changes at all.
<mrf> merlinofchaos: cool, thanks doesn't sound too terrible
<mrf> merlinofchaos: anything about this issue point to one of those at first glance http://drupal.org/node/1285636
<Druplicon> http://drupal.org/node/1285636 => Incompatibility with Views 3.x? => User Relationships, Views, normal, active, 10 comments, 1 IRC mention
<merlinofchaos> mrf: Ahh, that might be bitten by the fact that the implicit relationship from node to node author was removed, and the code that tries to auto-add that relationship if it detects that it was previously in use fails if there are multiple 'user' base tables.
<merlinofchaos> mrf: So that *may* just be solved by adding "Node: Author" as a relationship.
<mrf> merlinofchaos: that should definitely get me somewhere to get started, thanks!

In case someone else wants to get started on this before I get a chance. :)

inky@inky3d.com’s picture

I don't suppose anyone has been able to start looking at this yet?

My client wants to take the site live in the next week and wondering whether we'll have the UR views available.
if I could give him a time-frame it would also be helpful (a week, two weeks? A month?)

mrf’s picture

I can't promise any time to this myself in the next couple of weeks. But if someone else has a chance to look at it I will definitely find the time to review and commit any necessary patches.

broncomania’s picture

Same Problem here.

gateway69’s picture

I also have this issue.. anyone found a solution outside of backing up to an alpha?

kevstav13’s picture

FileSize
1.3 MB

Backing up to an earlier alpha version didn't do it for me, but I did have a previous 6.x-3.x-dev version before this last release, and backing up to that version saved me and I know longer get the "unknown column uid" error.

I've attached it. Hopefully it works out for all of you too.

vishun’s picture

Status: Active » Needs review
FileSize
967 bytes

I believe I may have fixed the issue. I decided to focus on the 2nd database query error and basically it was trying to do a JOIN on the user_relationships database table with the database field 'uid' which is non-existent. Since JOINs and such are usually related to Relationships, I focused on that area of UR. A patch that fixes those 2 errors are attached, but whether or not it affects anything else regarding UR and views, not sure yet. Please test and let us know.

Status: Needs review » Needs work

The last submitted patch, user_relationship_views.views_.vishun.inc_.patch, failed testing.

vishun’s picture

Status: Needs work » Needs review
FileSize
1.66 KB

-p1 style patch

The last submitted patch, user_relationship_views.views_.vishun.inc_.patch, failed testing.

vishun’s picture

Status: Needs work » Needs review
Issue tags: -6.x-1.1

#19: user_relationship_views.views_.vishun.inc_.patch queued for re-testing.

bah :) its 2 simple changes

user_relationships/user_relationship_views/user_relationship_views.views.inc
line 89 change 'uid' to 'requester_id'

      'relationship' => array( // this relationship brings in all fields the users table offers
        'base' => 'users',
        'field' => 'requester_id',
        'label' => 'requester',
        'help' => t('Bring in data about the user who started the relationship, or link to relationships that they have established'),
      ),

user_relationships/user_relationship_views/user_relationship_views.views.inc
line 120 change 'uid' to 'requestee_id'

      'relationship' => array( // this relationship brings in all fields the users table offers
        'base' => 'users',
        'field' => 'requestee_id',
        'label' => 'requestee',
        'help' => t('Bring in data about the user who accepted the relationship, or link to relationships that other users have established to this one'),
      ),

Issue tags: +6.x-1.1

The last submitted patch, user_relationship_views.views_.vishun.inc_.patch, failed testing.

knic’s picture

Status: Needs review » Needs work
Issue tags: +6.x-1.1

Working for me so far so good...

Berdir’s picture

That's not a -p1 patch, it's the opposite.

I suggest you use git to create patches, because that isn't a unified patch format either.

vishun’s picture

vishun’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, relationship_fix-1285636-25.patch, failed testing.

inky@inky3d.com’s picture

I found another thread on this same topic, where the patch supplied has resolved the UR / views that were giving me issues:

http://drupal.org/node/1312956#comment-5168604

mrf’s picture

I'm leaving this open for 6.x but it looks like people have had success with the patch on the 7.x issue linked above. Can anyone confirm if that patch or the one posted here resolves the issue for them on 6.x-1.0 or dev?

broncomania’s picture

I tested it with 6.x-1.0 and views 3 alpha 4 and it works for me. Thx for your work!

mrf’s picture

Ok, the other side of that equation, anyone run this patch and can confirm it doesn't break views 2? I'll test both scenarios myself before adding this in but I'd like to know if anyone has tried it.

Aldus’s picture

6.x still has this problem. #16 hopefully solves it for me, but what happened to views after that version!? :|

ayalon’s picture

The path in #25 works. It's now on my live system.

Important: you have to clear the cache after applying this patch, because the views schema is cached.

mrf’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
FileSize
2.2 KB

Reported success on d6 with this patch from #1312956: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_relationships.uid' in 'on clause'. Credit to samhain and ghostthinker.

Anyone tried any of these patches with the Views 2.0 yet to make sure we're not breaking what used to work?

mrf’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, user_relationship_views.views_.inc_.patch, failed testing.

mrf’s picture

Status: Needs work » Needs review
Issue tags: -6.x-1.1
FileSize
2.48 KB

One more try with that patch, looks like we've moved things around a bit.

mrf’s picture

Did some click-around testing on both Views 2.x and 3.x and Drupal 6 with the patch from 37.

Everything seems to be working correctly, but would love to get some feedback on this particular patch from someone running customized views and on real production relationship data.

mrf’s picture

Note to self to remove duplicate line near #123 before committing this.

protoplasm’s picture

I can confirm that this cleared up my problem with Views 3 and User Relationships not working in a totally up-to-date 6.x. installation on a relatively complex production site. I had to make the changes manually. Legacy patch, non-git, patching didn't work.

neurovation.kiwi’s picture

hi folks,

it's not fixed with me. i had to change an additional thing (the relationship definition)

please review this patch

cu
kiwi

Status: Needs review » Needs work

The last submitted patch, user_relationship_views.views_.inc_.patch, failed testing.

protoplasm’s picture

I thought those relationships were fixed in #37. The patch in #37 failed to apply all of the changes when I used patch, so I made all the changes by hand and it worked.

#37 is working on a 2000 member social networking site with complicated UR relationships and filters. At least I can't see anything wrong yet and I've had no complaints--yet.

mrf’s picture

neurovation, your changes are a small subset of what is included in #37, what you have is basically the absolute minimum to get this working, but 37 includes some additional data that ends up making UR views a lot more flexible, and I'm pretty sure the left field would speed this views query up, but not so sure about why that one is there, but want to match the d7 version as closely as possible to leave open the ability to move UR views from 6-7.

gateway69’s picture

this getting pushed into a newer release?

mrf’s picture

Status: Needs work » Fixed

Committed to 6.x-1.x-dev

mrf’s picture

Since this was a pretty major bug for people on Views 3 (which now has a full release for 6) I went ahead and published 6.x-1.2 that includes this fix.

Status: Fixed » Closed (fixed)

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