Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug in Dashboard Catalogue filter #1889

Merged
merged 2 commits into from Jan 3, 2016
Merged

Fixed a bug in Dashboard Catalogue filter #1889

merged 2 commits into from Jan 3, 2016

Conversation

DNX
Copy link
Contributor

@DNX DNX commented Oct 25, 2015

Fixed a bug in Dashboard Catalogue when filter by upc and have multiple results.
Where is the right place to write some tests for this?

Fixed a bug in Dashboard Catalogue when filter by upc and have multiple results.
@DNX
Copy link
Contributor Author

DNX commented Oct 26, 2015

With Django 1.8.5 and Postgres 9.4.5 the sql query in this case will be:

SELECT "catalogue_product"."id", "catalogue_product"."structure", "catalogue_product"."upc", "catalogue_product"."parent_id", "catalogue_product"."title", "catalogue_product"."slug", "catalogue_product"."description", "catalogue_product"."product_class_id", "catalogue_product"."rating", "catalogue_product"."date_created", "catalogue_product"."date_updated", "catalogue_product"."is_discountable", "catalogue_product"."points", "catalogue_product"."points_calculator", "catalogue_productclass"."id", "catalogue_productclass"."name", "catalogue_productclass"."slug", "catalogue_productclass"."requires_shipping", "catalogue_productclass"."track_stock" FROM "catalogue_product" LEFT OUTER JOIN "catalogue_productclass" ON ( "catalogue_product"."product_class_id" = "catalogue_productclass"."id" ) WHERE ("catalogue_product"."parent_id" IS NULL AND ("catalogue_product"."id" = (SELECT U0."id" FROM "catalogue_product" U0 WHERE UPPER(U0."upc"::text) LIKE UPPER('%123%')) OR "catalogue_product"."id" = (SELECT U0."parent_id" FROM "catalogue_product" U0 WHERE UPPER(U0."upc"::text) LIKE UPPER('%123%')))) ORDER BY "catalogue_product"."date_created" DESC

and Postgres will return: ERROR: more than one row returned by a subquery used as an expression

With __in lookup the query will be:

SELECT "catalogue_product"."id", "catalogue_product"."structure", "catalogue_product"."upc", "catalogue_product"."parent_id", "catalogue_product"."title", "catalogue_product"."slug", "catalogue_product"."description", "catalogue_product"."product_class_id", "catalogue_product"."rating", "catalogue_product"."date_created", "catalogue_product"."date_updated", "catalogue_product"."is_discountable", "catalogue_product"."points", "catalogue_product"."points_calculator", "catalogue_productclass"."id", "catalogue_productclass"."name", "catalogue_productclass"."slug", "catalogue_productclass"."requires_shipping", "catalogue_productclass"."track_stock" FROM "catalogue_product" LEFT OUTER JOIN "catalogue_productclass" ON ( "catalogue_product"."product_class_id" = "catalogue_productclass"."id" ) WHERE ("catalogue_product"."parent_id" IS NULL AND ("catalogue_product"."id" IN (SELECT U0."id" FROM "catalogue_product" U0 WHERE UPPER(U0."upc"::text) LIKE UPPER('%123%'')) OR "catalogue_product"."id" IN (SELECT U0."parent_id" FROM "catalogue_product" U0 WHERE UPPER(U0."upc"::text) LIKE UPPER('%123%'')))) ORDER BY "catalogue_product"."date_created" DESC

And Postgres will return correctly multiple results.

@DNX
Copy link
Contributor Author

DNX commented Oct 26, 2015

@mvantellingen where is the right place to write a test in this case? I didn't find any that test the Dashboard Catalogue Views.

@mvantellingen
Copy link
Contributor

These tests will fail without this PR fix.
@DNX
Copy link
Contributor Author

DNX commented Oct 26, 2015

I wrote some tests that will fail without this PR fix

@mvantellingen mvantellingen added this to the 1.2 milestone Dec 12, 2015
mvantellingen added a commit that referenced this pull request Jan 3, 2016
Fixed a bug in Dashboard Catalogue filter
@mvantellingen mvantellingen merged commit ec04ef3 into django-oscar:master Jan 3, 2016
@mvantellingen
Copy link
Contributor

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants