Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This code causes an SQL error:
$query = db_update('node_type')
->fields(array(
'custom' => TRUE,
'locked' => FALSE,
))
->condition('type', 'article')
->execute();
The error message is:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'locked' at row 1: UPDATE {node_type} SET custom=:db_update_placeholder_0, locked=:db_update_placeholder_1 WHERE (type = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => 1 [:db_update_placeholder_1] => [:db_condition_placeholder_0] => article ) in field_convert_select() (line 37 of /Users/joachim/Sites/_sandbox/field_convert-HEAD/field_convert.admin.inc).
It appears the value of FALSE gets turned into an empty string.
Are there cases where this is the desired behaviour? If not, I think being able to pass FALSE and TRUE makes for more legible code.
Comments
Comment #1
Crell CreditAttribution: Crell commented#403840: Cast numeric values at the level of the DB driver
Frankly I think this is a won't fix, but that's still being discussed in the other thread.