PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘field_xxx_display’ cannot be null:

If you are using Features module to import/export sample data like for kickstart data for your new feature. If you are using the newest version dependent modules – uuid and uuid_featurs(7.x-1.0-alpha or above) of the Feature module, then you will get the following error at the time importing sample data that contains field referencing asset such as image, video,etc:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘field_xxx_display’ cannot be null:

The issue is that there appears to have a bug in uuid_features module of the newest version that strips away attribute ‘display’ from the sample import. One solution is to reattach back the missing attribute just before the sample data is saved. To do so, we use hook_node_presave() as following:

function MODULE-NAME_node_presave($node) {
    //fix  for sample data import where 'display' is striped away for field_xxx causing db syntax error at node_save
    if($field_instance = field_get_items('node', $node, 'field_xxx')){
        foreach($field_instance as $key => $field_ins){
            $node->field_xxx['und'][$key]['display'] = 1;
        }
    }

Here, in line 3, the field instance is retrieved for the node being imported. If it exists, then in line 4, we go through all of the instances of that field and add the attributed ‘display’ that was striped away by uuid_features module. Note, that the word ‘display’ is removed from ‘field_xxx_display’ as mentioned in the error message because its added by Drupal to store the data