Dear friends,
First, thanks for this wonderful module.
I noticed this little SQL error:
query: SELECT SUM(uop.qty) FROM uc_orders uo LEFT JOIN uc_order_products uop
ON uo.order_id = uop.order_id WHERE uo.order_status =
"completed" AND uo.uid = 1 AND uop.nid = 31 ORDER BY
uop.nid in
/home/html/gooze.eu/www/sites/all/modules/uc_restrict_qty/uc_restrict_qty.module
on line 284.
In fact, there are two issues:
* First, double-quotes are used for column names, not values
so the query should be uo.order_status = 'completed'
as explained here: http://drupal.org/node/555548
* Secondly, under PostgreSQL there is a need for an additional GROUP BY
as explained here: http://drupal.org/node/555530
so the query should be GROUP BY uop.nid ORDER BY uop.nid
In fact, the final PHP code is:
284 $bought_qty = db_result(db_query('SELECT SUM(uop.qty) FROM {uc_orders} uo LEFT JOIN {uc_order_products} uop ON uo.order_id = uop.order_id WHERE uo.or der_status = 'completed' AND uo.uid = %d AND uop.nid = %d GROUP BY uop.nid ORDER BY uop.nid', $user->uid, $form_values['nid']));
Feel free to apply ASAP, as it is safe.
Comment | File | Size | Author |
---|---|---|---|
#6 | uc_restrict_qty.diff | 1.09 KB | grub3 |
#2 | uc_restrict_qty.diff | 1.11 KB | grub3 |
Comments
Comment #1
grub3 CreditAttribution: grub3 commentedSorry, the code is:
284 $bought_qty = db_result(db_query("SELECT SUM(uop.qty) FROM {uc_orders} uo LEFT JOIN {uc_order_products} uop ON uo.order_id = uop.order_id WHERE uo.or der_status = 'completed' AND uo.uid = %d AND uop.nid = %d GROUP BY uop.nid ORDER BY uop.nid", $user->uid, $form_values['nid']));
Tested on a production server.
Comment #2
grub3 CreditAttribution: grub3 commentedPlease apply this patch. Setting it to reviewed as it is very straightforward.
Comment #3
grub3 CreditAttribution: grub3 commentedSorry, this is the patch file:
Comment #4
grub3 CreditAttribution: grub3 commentedThe patch did not seem to upload. Here it is in text:
There is no way we should add 'ORDER BY uop.nid' as it is useless and it makes an SQL error under PostgreSQL.
Comment #5
grub3 CreditAttribution: grub3 commentedComment #6
grub3 CreditAttribution: grub3 commentedComment #7
RaulMuroc CreditAttribution: RaulMuroc commentedClosed due to lack of activity.