Hello,

I'm trying to import node who contains files. I have set node mapping of the field file and field image. It's working with image but no with file. I obtain a error message after the importation : SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'fid' cannot be null.
Anyone have a idea for this error ?

Thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Leksat’s picture

Status: Active » Needs review
FileSize
568 bytes

I also have this error using the latest dev version. I suppose it's related to #1080386: Add mapping for title and alt fields on images..
In my case the error appears when I import image file and it's alt text, and when file can't be downloaded. So the file field added to an entity in file_feeds_set_target() looks like this:

array(
  'und' => array(
    0 => array(
      'alt' => 'Some text',
    )
  )
)

Attached patch that fixes issue for me.

vitchy’s picture

I tried your patch and i haven't any message now but no file was uploaded in drupal file system and database for field file.
It's working for you (not for image field but for a custom file field in node content type) ?

twistor’s picture

Assigned: Unassigned » twistor
Status: Needs review » Postponed (maintainer needs more info)

What do the values look like that you are mapping to the uri field?

vitchy’s picture

I created a field type "file" with cck in node content type and i mapped the "File: URI" target with feed node processor.
In my CSV file, for my "file" field mapping, i set a url value for the URI. And nothing is uploaded in system file and no value set in database.
But it's working well with image field.

msamavi’s picture

The same problem here!

jackhutton’s picture

Getting this error as well: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'fid' cannot be null
log message:

DOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'fid' cannot be null: INSERT INTO {file_usage} (fid, module, type, id, count) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => file [:db_insert_placeholder_2] => node [:db_insert_placeholder_3] => 505 [:db_insert_placeholder_4] => 1 ) in file_usage_add() (line 662 of /srv/bindings/0d7aab820bdd44d0931100442a50f17b/code/includes/file.inc).

tried a few different approaches but no success.. does the above patch apply to the october 1st 7.x-2.x-dev version? Didn't apply for me..but, that could be me..
be great to attach images to nodes again.
thanks

mjcarter’s picture

Edit - The issue I was getting originally appears to be related to the media_feeds module. Just upgraded to the dev version of feeds, now I get the same error as everyone else. Applied patch by Leksat - errors disappear and import works, but file fields are empty in the imported users.

Anonymous’s picture

My problem stemmed from having certain characters in the file names, e.g. dash

wroxbox’s picture

feeds-file_save_fid_null-2077343-2.patch is for alpha7
feeds-file-download-sql-error-2077343-9.patch is for 2.x-dev

uladzimir.karol’s picture

>>>feeds-file-download-sql-error-2077343-9.patch is for 2.x-dev
Your patch resolved the issue. Thank you.

web226’s picture

feeds-file-download-sql-error-2077343-9.patch also worked for me with 2.x-dev. Thank you very much.

twistor’s picture

Assigned: twistor » Unassigned
Status: Postponed (maintainer needs more info) » Closed (duplicate)

This was fixed a long time ago.