Column 'cart' in where clause is ambiguous

Created on 11 April 2024, 7 months ago
Updated 9 May 2024, 6 months ago

The cart submodule introduces a "cart <> 1" filter on the default commerce_orders view for all displays. This causes a fatal error if you add a relationship to entities of the same type to the default display or any subsequently added displays.

Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'cart' in where clause is ambiguous:...

This might arguably be a feature request since vanilla Commerce doesn't have this issue and one can clone the default view or use a new view for one's needs, but the forced filter is at the very least not graceful.

Steps to reproduce:

  • Add an entity reference field of type commerce_order to any commerce_order bundle.
  • Add a commerce_order relationship to the commerce_orders view, based on the value from the entity reference field.
  • Access the view path and notice the fatal error.

Proposed solution:

Remove commerce_cart.views_execution.inc which contains commerce_cart_views_query_alter which only adds this forced filter, and move the filter to the yml definition of the view in the order submodule.

Remaining tasks:

Create an update hook to add the filter to the "commerce_order..default" entity view displays of all bundles.
Update documentation.

🐛 Bug report
Status

Fixed

Version

2.38

Component

Cart

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024