PDOException when populating file field programaticalily? I'm creating a drupal commerce product programatically and trying to populate it with a file using the following code:

$new_product = commerce_product_new($product_type);

$new_product-&gt;created = $new_product-&gt;changed = time();

$new_product-&gt;field_pdf[LANGUAGE_NONE][0] = $extras['file'];

commerce_product_save($new_product);


This is the value of $extras['file'];

Keys: fid, uri, filename, filemime, uid, status, timestamp, filesize Values: 135, public://pdfs/test2_106.pdf, test2.pdf, application/pdf, 0, 1, 1356742160, 3908

My problem is I get this error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'field_pdf_display' cannot be null: INSERT INTO {field_data_field_pdf} (entity_type, entity_id, revision_id, bundle, delta, language, field_pdf_fid, field_pdf_display, field_pdf_description) 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, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] =&gt; commerce_product [:db_insert_placeholder_1] =&gt; 113 [:db_insert_placeholder_2] =&gt; 115 [:db_insert_placeholder_3] =&gt; policy [:db_insert_placeholder_4] =&gt; 0 [:db_insert_placeholder_5] =&gt; und [:db_insert_placeholder_6] =&gt; 128 [:db_insert_placeholder_7] =&gt; [:db_insert_placeholder_8] =&gt; ) in field_sql_storage_field_storage_write() (line 448 of /var/www/clients/client1/web10/web/modules/field/modules/field_sql_storage/field_sql_storage.module).


I have absolutely no idea what the problem might be. Can anyone point me in the right direction?
A file field item is not the same thing as a file object/array. You need to set the keys as defined in file_field_schema, which means fid, display and description.