mmikkel / CpSortableCustomColumns-Craft

Adds custom fields to sortable attributes in element indexes
41 stars 5 forks source link

Bug with Commerce active/inactive carts view #8

Closed bossanova808 closed 7 years ago

bossanova808 commented 8 years ago

Hi

This breaks the active/inactive carts vie in Craft Commerce

I believe you're wrapping a whole query and adding an orderby clause - which is rasing

2016/06/29 04:43:15 [error] [system.db.CDbCommand] CDbCommand::fetchAll() failed: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'dateUpdated' in order clause is ambiguous.

...because it needs to be orders.dateUpdated to be unambiguous.

Well that's based on what Luke said :)

I haven't had a chance to dig in & try and fix (I'm launching something Friday) - but thought I'd raise this in case it was an easy fix for you!

bossanova808 commented 8 years ago

Further info - the bug only appear with Mysql 5.5, on 5.7 it does not get raised.

(The bug results in nothing being shown in the view and the 'an error has occured' labels at the top)

mmikkel commented 8 years ago

Hey @bossanova808, sorry for the late reply and thanks for reporting. I'll look at this ASAP.

bossanova808 commented 8 years ago

Luke knows about it and mentioned maybe doing a PR - I think if you ask him he'll probably have a quick solve for it.

terryupton commented 7 years ago

I have experience this issue too. Do you have an ETA on a fix at all?

Thanks.

lukeholder commented 7 years ago

Looks like it is only affecting the active and inactive cart screens, because those sources have a dateUpdated criteria attribute built into them.

mmikkel commented 7 years ago

Hi gents, sorry about the delay on this one. I've figured out what's happening here, and will hopefully have a patch out very soon. Thanks for contributing!

terryupton commented 7 years ago

Hi @mmikkel any update on this at all? I am nearing releasing a Craft Commerce site soon. :-)

engram-design commented 7 years ago

If anyone is still looking for a temp fix for this, its a little added JS hack. At https://github.com/mmikkel/CpSortableCustomColumns-Craft/blob/master/cpsortcols/resources/cpsortcols.js#L102 add the following:

if ($('body').hasClass('commerceordersindex') && attribute == 'dateUpdated') {
    attribute = 'orders.dateUpdated';
    $header.attr('data-attribute', attribute).data('attribute', attribute);
}
mmikkel commented 7 years ago

I've added the fix from @engram-design to v. 1.1.2.