When Sorting by Price an SQL Error is Produced

Posts: 13
Joined: 04/23/2008
Bug Finder

Greetings,

When sorting products by price on Ubercart 5.x-1.0 using postgresql a database query error is produced:

SELECT DISTINCT(n.nid), n.sticky, n.title, n.created, p.model, p.ordering FROM node n INNER JOIN term_node tn ON n.nid = tn.nid INNER JOIN uc_products AS p ON n.vid = p.vid WHERE tn.tid = 6 AND n.status = 1 AND n.type IN ('product') ORDER BY p.sell_price ASC LIMIT 120 OFFSET 0;

ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list

The problem is that the item in the ORDER BY expression is not included in the SELECT list.

Changing line #867 of file uc_catalog/uc_catalog.module from:

$sql = "SELECT DISTINCT(n.nid), n.sticky, n.title, n.created, p.model, p.ordering

to

$sql = "SELECT DISTINCT(n.nid), p.sell_price, n.sticky, n.title, n.created, p.model, p.ordering

fixes the problem.

Thank you for your time.

Regards,

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

Must have forgotten to add that one when I put in the model and ordering fields. Thanks.