uc_stock_adjust() SQL syntax error

Project:Ubercart Contributions
Component:Code
Category:
Priority:normal
Assigned:Unassigned
Status:active
Description
Project: 
Ubercart

In beta 3, a call to uc_stock_adjust() causes an SQL syntax error. The problem is an over-enthusiastic use of single quotes. The patch to fix the problem follows:

--- uc_stock.module     (revision 14)
+++ uc_stock.module     (revision 15)
@@ -326,7 +326,7 @@
 */
 function uc_stock_adjust($sku, $qty) {
   $op = ($qty < 0) ? "-" : "+";
-       db_query("UPDATE {uc_product_stock} SET 'stock' = 'stock' $op %d WHERE 'sku' = '%s'", (int) abs($qty), $sku);
+  db_query("UPDATE {uc_product_stock} SET stock = stock $op %d WHERE sku = '%s'", (int) abs($qty), $sku);
 }
 
 /**

(the revision numbers refer to our local Subversion repository not the Ubercart Bazaar repository)

Shawn Conn's picture
Offline
Administrator
Joined: 08/07/2007
Juice: 916
Re: uc_stock_adjust() SQL syntax error

Yeah, its amazing how many times I looked at that and saw backticks and not quotes. Fixed & committed.

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine