Hello, it's me again. I know I might be a pain in the ... lately, but views is great, so why not to make it perfect? ;)

Now I have in my chain of joins 5 tables, let's call them a, X, b, Y and Z. Fun fact is, X and Y share a field that should be joined between them all. Now connections are: a->X, b->Y, Y->Z, and I can't reorder them any sane way. I mean, if I'll try to connect a to b via X or Y, I'll get hella lot of duplicates when I'm not actually using any X, Y or Z data. Overriding join handler is out of question, as Y->Z join is perfectly authorized to not have any idea about X at all. There might be no X in table list sometimes, and that's where using 'extra' failed me.

I was meant to write it as a feature request:
Add $data['tablename']['table']['join-universal'] with the list of fields that always should be used if they are on join-universal list of more than one table in a query. That way joining many data tables + their corresponding language tables would be far easier, just add language_id to universal list of all tables that ahve it, right? And it would be nice to have UI option for the very same thing when dealing with data that's already there. I'm pretty sure I've seen quite some support requests with the very same problem at their core already.

So, if it is possible now, please show me the way. If it's not, I'll change it into feature request and start to write patch the day after tomorrow (after >24 hours, that is).

Comments

Mołot’s picture

Category: support » feature

OK, so let's make the patch happen.

Mołot’s picture

Component: Miscellaneous » Code

Draft:
I need to create an array looking like this:

 $common_fields = array(
  'field name 1' => array(
    'table 1',
    'table 2',
    'table 3',
  ),
  'field name 2' => array(
    'table 1',
    'table 3',
  ),
); 

Then each time new table is added to a query, this table needs to be checked against common fields defined by new table. If they are found, condition should be added and table updated.

With inner joins it will be simple, we can just join to the last table that had given field. With outer joins, where given table may as well be purely optional, it's starting to get tricky.