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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3440271-3.patch | 963 bytes | tbkot |
| column-cart-in-where-clause-is-ambiguous.patch | 2.26 KB | ts.ag |
Comments
Comment #2
jsacksick commentedThe patch is incorrect. It cannot be done this way... Since the commerce_order module doesn't depend on commerce_cart which is the reason why the filter is added like it is today.
Comment #3
tbkot commentedComment #6
jsacksick commentedCommitted, thanks Dmytrii!