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.

CommentFileSizeAuthor
uc_views.views_.tablejoin.patch800 bytessetvik

Comments

madsph’s picture

Assigned: Unassigned » 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?

PeteS’s picture

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.)

madsph’s picture

Status: Active » Fixed

Great - thank you for reporting :-)

Status: Fixed » Closed (fixed)

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