Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix duplicate result if name contains SKU #2409

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

jphpsf commented Jan 9, 2013

My Spree app happens to have product names that includes part of the SKUs. When I create an order in the admin, the products autocomplete then return duplicated results (because both the SKU and the name matches)

Step to reproduce: in the Spree admin, create a product named "ABC test" with a SKU "ABC123". Go to the Orders tab and create a New Order. Search for "ABC" in the product field. When the autocomplete results appears you should see a duplicate entry for "ABC test".

Expected behavior: no duplicate entries :)

Broken behavior: duplicate entries!

Fix: the fix is trivial. In the product controller, I added a call to #uniq at the end of the #collection method. Also added a test to verify the behavior.

Cheers!

Member

radar commented Jan 14, 2013

This PR breaks tests on PostgreSQL: https://travis-ci.org/spree/spree/jobs/4038324. Could you please take a look at that?

jphpsf commented Jan 14, 2013

Sure thing. It looks like it's breaking the products HTML table. Should be easy to fix.

Member

radar commented Jan 14, 2013

Looks like an SQL error: https://travis-ci.org/spree/spree/jobs/4038324/#L99.
I think we tried addressing this previously and ran into some difficulties.

On Mon, Jan 14, 2013 at 11:57 AM, JP notifications@github.com wrote:

Sure thing. It looks like it's breaking the products HTML table. Should be
easy to fix.


Reply to this email directly or view it on GitHubhttps://github.com/spree/spree/pull/2409#issuecomment-12203832.

jphpsf commented Jan 21, 2013

I understand know why I did not see the test failure. By default rake spec uses sqlite which did not have the problem. Anyway, gonna need to spend some time on this one :)

jphpsf commented Jan 22, 2013

The fix was pretty simple. Because the bug was really only affecting the JSON API, I moved the uniq call to the XHR block. Tests are passing locally with postgresql and sqlite.

@radar radar added a commit that referenced this pull request Jan 24, 2013

@jphpsf @radar jphpsf + radar Fix duplicate result if name contains SKU
Fixes #2409
3eb0ad9
Member

radar commented Mar 6, 2013

I think this one is fixed now :)

@radar radar closed this Mar 6, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment