According to the help docs, 'extra type' is a key on 'extra':

extra
    Either a string that's directly added, or an array of items. Each item is, itself, an array:

    field
        Field or formula
    operator
        Similar to filters, this is the operator, such as >, <, =, etc. Defaults to = or IN.
    value
        Must be set. If an array, operator will be defaulted to IN.
    numeric
        If true, the value will not be surrounded in quotes, and %d will be used for its placeholder.
    extra type
        How all the extras will be combined. Either AND or OR. Defaults to AND.

However, the description is:
"How all the extras will be combined. Either AND or OR. Defaults to AND."
Which is a bit confusing -- if it's set on each extra, but it tells how to combine them all, surely there's redundancy?

Testing this, it looks like the description is correct, but the location of the key in the list is wrong.
If I put an extra type within the extra, they have no effect:

  // Image table, aliased for base table node.
  $data['image_node']['table']['group']  = t('Image');

  // Explain how this table joins to others.
  $data['image_node']['table']['join'] = array(
    'node' => array(
      // Directly links to node table.
      'left_field' => 'nid',
      'table' => 'image', // because image_node is an alias
      'field' => 'nid',
      'extra' => array(
        'image_size' => array(
          'field' => 'image_size',
          'extra type' => 'OR',
          // this will be set to the desired derivative size by the handler
          'value' => '****IMAGE_DERIVATIVE****',
        ),
        'image_size_fallback' => array(
          'field' => 'image_size',
          'extra type' => 'OR',
          'value' => 'IMAGE_ORIGINAL',
        ),
      ),
    ),
  );  
// I get ANDs in my query
<code>

If I set the extra type on the join, it works as expected:

<code>
  // Image table, aliased for base table node.
  $data['image_node']['table']['group']  = t('Image');

  // Explain how this table joins to others.
  $data['image_node']['table']['join'] = array(
    'node' => array(
      // Directly links to node table.
      'left_field' => 'nid',
      'table' => 'image', // because image_node is an alias
      'field' => 'nid',
          'extra type' => 'OR',
      'extra' => array(
        'image_size' => array(
          'field' => 'image_size',
          'extra type' => 'OR',
          // this will be set to the desired derivative size by the handler
          'value' => '****IMAGE_DERIVATIVE****',
        ),
        'image_size_fallback' => array(
          'field' => 'image_size',
          'value' => 'IMAGE_ORIGINAL',
        ),
      ),
    ),
  );  
// I get the OR as expected.
CommentFileSizeAuthor
#2 403678-join-extra_type-doc.patch714 bytesdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Following chat on IRC... bug is in sites/all/modules/views/help/api-tables.html -- extra type is in the wrong DL.

dawehner’s picture

Status: Active » Needs review
FileSize
714 bytes

Here is a patch to fix this bug in the documentation

esmerel’s picture

Status: Needs review » Reviewed & tested by the community

Looks ok to me

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed to all branches.

benoit.borrel’s picture

Hi,

Could someone fix it here (http://views-help.doc.logrus.com/help/views/api-tables) as well?

Thank you

dawehner’s picture

Assigned: Unassigned » merlinofchaos

Assign to merlinofchaos, afaik he has to cvs update.

Status: Fixed » Closed (fixed)

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