Hi,
I use Drupal 7.x-1-RC2 and Ubercart 7.x-3.x-beta1. When I'd like to add an attribute for a previously created product class, i get the following error message.
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'weightproduct' for column 'default_option' at row 1: INSERT INTO {uc_class_attributes} (aid, label, ordering, required, display, pcid, default_option) SELECT a.aid AS aid, a.label AS label, a.ordering AS ordering, a.required AS required, a.display AS display, :id AS pcid, :id AS default_option FROM {uc_attributes} a WHERE (aid = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 1 [:id] => weightproduct ) in uc_object_attributes_form_submit() (line 831 of uc_attribute.admin.inc).
As i see it's because two different placeholder is called as :id. My small patch is attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 998450_product_attributes.patch | 884 bytes | Island Usurper |
| product_class_attribute_bug.patch | 558 bytes | aries |
Comments
Comment #1
Island Usurper commentedGood catch. When I was testing it, I got a duplicate entry error on the {uc_product_options} table, which really surprised me. It seems when one query was changed to use drupal_write_record(), the very important 'nid' column wasn't added.
Comment #2
Island Usurper commentedSeems to work still, so committed. Thanks.
Comment #4
den33775 commentedGot very similar error assigning a user the ubercart role of administrator:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'expiration' at row 1: INSERT INTO {uc_roles_expirations} (uid, rid, expiration) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 15 [:db_insert_placeholder_1] => 3 [:db_insert_placeholder_2] => ) in uc_roles_grant() (line 1252 of /.../modules/ubercart/uc_roles/uc_roles.module).
(Implies value must be between 3 and 15 years, but doesn’t check for this in field validation). Add field validation check and allow 1 and higher, not limit to 3 to 15. When I saw this error and entered a value of between 3 and 15 years for the duration of the UC role assignment, the error did not appear.
Unfortunately, although I have used a few programming languages, I'm new to this one so can't help by providing a patch of my own. I could probably edit to remove upper 15 limit and reduce lower from 3 to 1, but I don't know if you've put those limits in for a reason, and I'm not sure how to validate the input properly and report an on-screen instruction that boundaries of input exceeded. :S Hope you can help? Meanwhile, I'll work around it by sticking to values between 3 and 15 hours/days/weeks/months/years. :)
Best wishes