malformed SQL-Statement in uc_cart.module with postgresql

Posts: 4
Joined: 09/03/2008
Bug Finder

I get the following error when I log in with an useraccount which has some products in the cart:

warning: pg_query() [function.pg-query]: Query failed: ERROR: operator does not exist: character varying = integer LINE 1: DELETE FROM uc_cart_products WHERE cart_id = 1 ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. in /var/www/drupal/includes/database.pgsql.inc on line 125.

I found the error on line 590 in uc_cart.module

db_query("DELETE FROM {uc_cart_products} WHERE cart_id = %d", $uid);

it has to be

db_query("DELETE FROM {uc_cart_products} WHERE cart_id = '%d'", $uid);

because cart_id is not a number.

Posts: 5353
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Interesting that it chokes... I'm making the change in core. Looks pretty non-critical to me for MySQL users. Will test on the Livetest.