Import fails with following error:

SQLSTATE[HY000]: General error: 1364 Field 'feed_nid' doesn't have a default value

on feeds_item_info_save function.

I solved the issue loading feed item info just after loading node to process.
FeedsSelfNodeProcessor.inc, line 29:

  public function process(FeedsSource $source, FeedsParserResult $parser_result) {
    ...
    $node = node_load($source->feed_nid, NULL, TRUE);
    $node->feeds_item = feeds_item_info_load($this->entityType(), $node->nid);
    ...
  }
CommentFileSizeAuthor
#1 missing_feed_nid-1139276-1.patch541 bytesguillaumev

Comments

guillaumev’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new541 bytes

I can confirm this works. Here is the attached patch...

jonathan_hunt’s picture

Status: Reviewed & tested by the community » Needs work

I've applied the patch above, but still get "SQLSTATE[HY000]: General error: 1364 Field 'feed_nid' doesn't have a default value"

[edit] I've installed a fresh Drupal 7, Feeds etc. and still get the error after applying the patch above.

jonathan_hunt’s picture

In my case the patch suggested above wasn't working because no row for the Feed Node exists in feeds_item table, so the feeds_item_info_load() suggested in #1 doesn't add necessary data.
The following is working for me, but I'm not sure it's the best solution because I'm not very familiar with Feeds. For example BusinessDataHTTPFetcher is specific to my project.

diff --git a/modules/feeds_selfnode_processor/FeedsSelfNodeProcessor.inc b/modules/feeds_selfnode_processor/FeedsSelfNodeProcessor.inc
index fb48af8..9f9e332 100755
--- a/modules/feeds_selfnode_processor/FeedsSelfNodeProcessor.inc
+++ b/modules/feeds_selfnode_processor/FeedsSelfNodeProcessor.inc
@@ -28,6 +28,15 @@ class FeedsSelfNodeProcessor extends FeedsNodeProcessor {
       return;
     }
     $node = node_load($source->feed_nid, NULL, TRUE);
+
+    // Force feeds_item data onto node.
+    $node->feeds_item->entity_type = $this->entityType();
+    $node->feeds_item->id = $source->id;
+    $node->feeds_item->feed_nid = $node->nid;
+    $node->feeds_item->imported = time();
+    $node->feeds_item->hash = $hash;
+    $node->feeds_item->url = $source->config['BusinessDataHTTPFetcher']['service'];
+
     $node->log = 'Updated by FeedsSelfNodeProcessor';
     $node->changed = REQUEST_TIME;
     $node->format = $this->config['input_format'];

twistor’s picture

Status: Fixed » Closed (fixed)

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