Hi,

I'm trying to use the table wizard, but can't seem to get the relationships to work.

I'm using:
Drupal 6.15
Views 2.11
Schema 1.x-dev (also tried with 1.7)
Table wizard 1.x-dev (also tried with 1.2)

Situation:
I have imported tables from a D5 to the database (used a prefix for all the tables). Now I want to link these tables together so that I get all data for a specific content type in one view, so I add a relationship between to tables (both on the nid field). Then I go back to the view of the base table and edit it, but the relationship is not added. Also tried a manual relationship but the relationship is not available. I don't get any errors, also tried if I got more data back when I disabled javascript for views but no warnings or anything else showed up.

Also tried it on a clean drupal installation (drupal 6.17), trying to create a relationship between 2 tables that are not already in views (eg. locales_source and locales_target). But I get the same result

Can anyone reproduce this?
Or does anybody know what the problem is?

Thanks

CommentFileSizeAuthor
#4 tw_tablebuild.patch534 bytesstijn.vanden.brande
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stijn.vanden.brande’s picture

Status: Active » Needs review

Hi,

after some debugging I discovered what was going wrong. I compared the arrays for the join data and found that there were some differences between what standard views generates and what TW generates. If you look at function '_tw_generate_views_relationship_data' in file 'tw_tablebuild.inc' for automatic relationships, the following array will be build up:

$tables[$rawtbl2]['table']['join'][$rawtbl1] = array(
        'table' => $rawtbl2,
        'left_field' => $col1,
        'field' => $col2,
      );

When comparing this to what standard views returns I adjusted the array to:

$tables[$rawtbl2]['table']['join'][$rawtbl1] = array(
        'handler' => 'views_join',
        'left_table' => $rawtbl1,
        'left_field' => $col1,
        'field' => $col2,
      );

and the relationships work. The relationships does not show up in the view edit form, but I can add the fields of the other table without any problems.

This is only for 'automatic' relationships, will look at the 'manual' relationships later and post it here too.

Greets,
Stijn

datawench’s picture

Where exactly did you make this adjustment? Where did you save your modified version of this join description?

stijn.vanden.brande’s picture

Hi,

I made the adjustment in file 'tw_tablebuild.inc' line 176 and below.
I'll try to create a patch for this today and then attach it here.

Greets,
Stijn

stijn.vanden.brande’s picture

FileSize
534 bytes

Okay, got the patch.
It's a day later, but its here.

If you need any more help trying to figure this out let me know.

Greets,
Stijn

datawench’s picture

Many thanks. This contributes a lot to my understanding of what's going on under the hood here.

soulfroys’s picture

Subscribe

soulfroys’s picture

Subscribe