I have a rule and component. Rule is reacting on updating existing node and looping thru its commerce_product entities to copy node:field_checkbox value to commerce_product:field_checkbox.
The rule and component is working when having the field checked, but when I'm trying to uncheck and save it, I get SQL error:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'field_checkbox_value' at row 1: INSERT INTO {field_data_field_checkbox} (entity_type, entity_id, revision_id, bundle, delta, language, field_checkbox_value) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => commerce_product [:db_insert_placeholder_1] => 2843 [:db_insert_placeholder_2] => 3050 [:db_insert_placeholder_3] => product [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => ) in field_sql_storage_field_storage_write() (line 448 of modules/field/modules/field_sql_storage/field_sql_storage.module).
Comment | File | Size | Author |
---|---|---|---|
#6 | 1600306-entity-boolean-set.patch | 1.16 KB | mrfelton |
#2 | rules_sync_field_checkbox.txt | 609 bytes | iMiksu |
#2 | rules_update_field_checkbox.txt | 675 bytes | iMiksu |
Comments
Comment #1
mitchell CreditAttribution: mitchell commentedComment #2
iMiksuI tested this in Commerce Kickstart so it should not contain any custom stuff there.
Note that this rule works when checking the field, but not when unchecking...
My rules and setup:
rules_sync_field_checkbox
rules_update_field_checkbox
Node
Commerce product
Comment #3
Ryssbowh CreditAttribution: Ryssbowh commentedSame problem,
I have a Rule which copy the value from a boolean field to a new boolean field.
message:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'field_is_author_value' at row 1: INSERT INTO {field_data_field_is_author} (entity_type, entity_id, revision_id, bundle, delta, language, field_is_author_value) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 181 [:db_insert_placeholder_2] => 181 [:db_insert_placeholder_3] => request_agreed [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => ) in field_sql_storage_field_storage_write() (line 448 of /home/bobo/Documents/Programmation/Web/drupal-7.14_test/modules/field/modules/field_sql_storage/field_sql_storage.module).
The error occurs only when the value is copied from another field, if the value is set "manually" by Rule it works.
the Rule:
The most interesting is the two actions which throw the error:
Comment #4
mrfelton CreditAttribution: mrfelton commentedCan confirm this bug. If you are setting the value of a checkbox field from another, it woks ok if the source field is checked. But if it's unchecked then there is a fatal error as above. It's trying to set the field to an empty value, rather than a boolean 0.
Comment #5
mrfelton CreditAttribution: mrfelton commentedI think the issue is that the checkbox is being returned as a true boolean (empty value), but the underlaying field expects an integer value. So, when the field value is loaded from one field its empty, as opposed to a 0 which is required to rite the data.
The typecasting in http://drupal.org/files/issues/1071814-entity-boolean.patch is the problem. Comment it out and it resolves the issue. But, there is probably a better way to fix this.
Comment #6
mrfelton CreditAttribution: mrfelton commentedThis is an Entity API issue. Attached patch does the necessary conversion from boolean back to integer in entity_metadata_field_property_set().
Comment #7
drupov CreditAttribution: drupov commentedI'm getting a similiar error when trying to create nodes with devel generate content and the content type includes a entity reference field:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'company' for column 'field_company_target_id' at row 1: INSERT INTO {field_data_field_company} (entity_type, entity_id, revision_id, bundle, delta, language, field_company_target_id) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 189 [:db_insert_placeholder_2] => 189 [:db_insert_placeholder_3] => project [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => company ) in field_sql_storage_field_storage_write() (line 448 of /var/www/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module).
The column "field_company_target_id" in the "field_data_field_company" should get a integer value (for the id of the node being referenced). However the value passed in is just a string "company". The entity reference field itself has a label "Company" and a machine name "field_company"...
Comment #8
kristofferwiklund CreditAttribution: kristofferwiklund commentedThe problem with entity reference and devel generate content in comment #7 is a bug in Entity reference project.
Here is the issue and a working patch
http://drupal.org/node/1852112#comment-6786574
Comment #9
geek-merlinpatch from #6 solves the issue, works like a charm and looks good code-wise.
daring to rise prio as setting bools from rules (which rhymes well also) is a quite common use case.
Comment #10
sebdec CreditAttribution: sebdec commentedthe patch from #6 works for me too
it is validated?
Comment #11
fagoThanks, committed.