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).

Files: 

Comments

Status:Active» Postponed (maintainer needs more info)

Component:Rules Engine» Rules Core
Status:Postponed (maintainer needs more info)» Active
StatusFileSize
new59.14 KB
new55.12 KB
new675 bytes
new609 bytes

I 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_sync_field_checkbox" : {
    "LABEL" : "Sync field_checkbox",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_update" ],
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_product" } }
    ],
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "node:field-product" ] },
          "ITEM" : { "commerce_product" : "Commerce product" },
          "DO" : [
            { "component_rules_update_field_checkbox" : { "node" : [ "node" ], "commerce_product" : [ "commerce_product" ] } }
          ]
        }
      }
    ]
  }
}

rules_update_field_checkbox

{ "rules_update_field_checkbox" : {
    "LABEL" : "Update field_checkbox",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "node" : { "label" : "Node", "type" : "node" },
      "commerce_product" : { "label" : "Commerce product", "type" : "commerce_product" }
    },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "commerce-product" ], "field" : "field_checkbox" } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_checkbox" } }
    ],
    "DO" : [
      { "data_set" : {
          "data" : [ "commerce-product:field-checkbox" ],
          "value" : [ "node:field-checkbox" ]
        }
      }
    ]
  }
}

Node


Commerce product

Same 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:

{ "rules_create_request_agreed_when_both_agree" : {
    "LABEL" : "create request agreed when both agree",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_update" ],
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "request_user" : "request_user" } }
        }
      },
      { "data_is" : { "data" : [ "node:field-agree" ], "value" : "16" } },
      { "node_is_of_type" : {
          "node" : [ "node:field-request-user" ],
          "type" : { "value" : { "request_user" : "request_user" } }
        }
      },
      { "data_is" : { "data" : [ "node:field-request-user:field-agree" ], "value" : "16" } }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "request_agreed",
            "param_title" : [ "node:title" ],
            "param_author" : [ "node:author" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created_1" : "Created entity 1" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created-1:field-request" ],
          "value" : [ "node:field-request" ]
        }
      },
      { "data_set" : {
          "data" : [ "entity-created-1:field-time" ],
          "value" : [ "node:field-time" ]
        }
      },
      { "entity_save" : { "data" : [ "entity-created-1" ], "immediate" : 1 } },
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "request_agreed",
            "param_title" : [ "node:title" ],
            "param_author" : [ "node:field-request-user:author" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created2" : "Created entity 2" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created2:field-time" ],
          "value" : [ "node:field-time" ]
        }
      },
      { "data_set" : {
          "data" : [ "entity-created2:field-request-agreed" ],
          "value" : [ "entity-created-1" ]
        }
      },
      { "data_set" : {
          "data" : [ "entity-created2:field-request" ],
          "value" : [ "node:field-request" ]
        }
      },
      { "entity_save" : { "data" : [ "entity-created2" ], "immediate" : 1 } },
      { "data_set" : {
          "data" : [ "entity-created-1:field-request-agreed" ],
          "value" : [ "entity-created2" ]
        }
      },
      { "data_set" : {
          "data" : [ "entity-created-1:field-is-author" ],
          "value" : [ "node:field-is-author" ]
        }
      },
      { "data_set" : {
          "data" : [ "entity-created2:field-is-author" ],
          "value" : [ "node:field-request-user:field-is-author" ]
        }
      },
      { "entity_delete" : { "data" : [ "node:field-request-user" ] } },
      { "entity_delete" : { "data" : [ "node" ] } },
      { "drupal_message" : { "message" : "RULE create request agreed when both agree, node is author : [node:field-is-author], node 2 is author [node:field-request-user:field-is-author]" } },
      { "redirect" : { "url" : "node\/[node:field-request:nid]" } }
    ]
  }
}

The most interesting is the two actions which throw the error:

{ "data_set" : {
          "data" : [ "entity-created-1:field-is-author" ],
          "value" : [ "node:field-is-author" ]
        }
      },
{ "data_set" : {
          "data" : [ "entity-created2:field-is-author" ],
          "value" : [ "node:field-request-user:field-is-author" ]
        }
      },

Version:7.x-2.1» 7.x-2.x-dev

Can 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.

I 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.

Project:Rules» Entity API
Version:7.x-2.x-dev» 7.x-1.x-dev
Component:Rules Core» Entity property wrapper
Status:Active» Needs review
StatusFileSize
new1.16 KB
Test request sent.
[ View ]

This is an Entity API issue. Attached patch does the necessary conversion from boolean back to integer in entity_metadata_field_property_set().

I'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"...

The 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

Priority:Normal» Major
Status:Needs review» Reviewed & tested by the community

patch 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.

the patch from #6 works for me too
it is validated?

Status:Reviewed & tested by the community» Fixed

Thanks, committed.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.