hook_views_data bug: table stripped from field in query for uc_orders fields; breaks node queries if fieldname ambiguous

setvik - June 8, 2009 - 14:53
Project:Ubercart Views
Version:6.x-2.0
Component:Code
Category:bug report
Priority:critical
Assigned:madsph
Status:closed
Description

The table gets stripped from fields in the views query for oc_orders fields; this breaks node queries where the included oc_orders fields have the same name as a field in another table (e.g. created)

To reproduce error:
- create a node view, add a page display, and set the path
- add any node field (node title for example)
- add the Ubercart Order: Order Creation Date

Save and view the new view.

The problem is due to some errors in how uc_orders is joined with the node table in hook_views_data()

See attached fix.

AttachmentSize
uc_views.views_.tablejoin.patch800 bytes

#1

madsph - June 9, 2009 - 06:39
Assigned to:Anonymous» madsph

I think this is a duplicate of #465420: Product nid and/or title as argument - although I think you make the join slightly different in your patch. I can't reproduce the bug though with my version so I think it is fixed.

In the current branch (not released yet - but in cvs) the join is made in the following way:

  $data['uc_order_products']['table']['join'] = array(
    'uc_orders' => array(
      'left_field' => 'order_id',
      'field' => 'order_id',
    ),
  );
  $data['node']['table']['join'] = array(
    'uc_orders' => array(
      'left_table' => 'uc_order_products',
      'left_field' => 'nid',
      'field' => 'nid',
    ),
    'uc_order_products' => array(
      'left_field' => 'nid',
      'field' => 'nid',
    ),
  );
  $data['uc_orders']['table']['join'] = array(
    'node' => array(
      'left_table' => 'uc_order_products',
      'left_field' => 'nid',
      'field' => 'nid',
    ),
    'uc_order_products' => array(
      'left_field' => 'order_id',
      'field' => 'order_id',
    ),
  );

Can you verify that that solves your issue, or am I reproducing it wrong?

#2

PeteS - June 10, 2009 - 18:07

This did the trick for me -- thanks for affirming that the problem was the node/uc_orders join.

(For others having problems, my symptom was plainly that as soon as I added the order created date as a filter, the view was trying to join node to uc_order_products using the order_id field, and obviously no such column exists in the node table.)

#3

madsph - June 11, 2009 - 05:18
Status:active» fixed

Great - thank you for reporting :-)

#4

System Message - June 25, 2009 - 05:20
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.