I have a node type with an attached field collection (an unlimited number can be added) but when I use devel generate to add content the field collection fields are always left blank ... not sure if this can be fixed here or if I should file an issue with "devel"

Comments

alanburke’s picture

Its an issue for this module. Devel looks after core, but not contrib [for the most part]
There is a hook that can be implemented for normal fields, but I'm not sure how it works for a field collection.

bleen’s picture

Title: Add support for devel gnereate » Add support for devel generate

fixing issue title

bleen’s picture

Status: Active » Needs review
StatusFileSize
new1001 bytes

This should do it...

cutesquirrel’s picture

StatusFileSize
new1.04 KB

Added language synchronization between host entity and field_collection_item.
I modified the previous patch to include it.

tim.plunkett’s picture

StatusFileSize
new1.04 KB

Don't hardcode 'node', grab the entity_type from the instance. Also rerolled to fix the implements comment and whitespace.

This works great on a basic test, but I wonder what would happen on nested field_collections. Can someone give that a try?

tim.plunkett’s picture

I tested this with nested field collections. If I can get one person to test it, I'll commit it.

bleen’s picture

Status: Needs review » Reviewed & tested by the community

I just gave it a shot with nested field collections as well ... good to go

tim.plunkett’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

aendra’s picture

Status: Closed (fixed) » Needs work

I'm having issues with this when trying to generate node types with nested field collections.

I get the following error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'field_children_revision_id' cannot be null: INSERT INTO {field_data_field_children} (entity_type, entity_id, revision_id, bundle, delta, language, field_children_value, field_children_revision_id) 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); Array ( [:db_insert_placeholder_0] => field_collection_item [:db_insert_placeholder_1] => 77 [:db_insert_placeholder_2] => 77 [:db_insert_placeholder_3] => field_relationships [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 76 [:db_insert_placeholder_7] => ) in field_sql_storage_field_storage_write() (line 448 of /home/x/modules/field/modules/field_sql_storage/field_sql_storage.module).

field_children is a field collection field inside another field -- field_relationships -- which is inside a content type Profile.

I'm also getting the same sort of error when I use Drush, for every field collection:

WD field_collection_item: PDOException: SQLSTATE[HY000]: General error: 1364 Field 'revision_id' doesn't have a default value: INSERT INTO {field_collection_item} (field_name) VALUES (:db_insert_placeholder_0); Array         [error]
(
    [:db_insert_placeholder_0] => field_university
)
 in drupal_write_record() (line 7106 of /home/x/includes/common.inc).
WD php: DatabaseTransactionNoActiveException:  in DatabaseConnection->rollback() (line 1019 of /home/x/includes/database/database.inc).                                                                                   [error]
DatabaseTransactionNoActiveException:  in DatabaseConnection->rollback() (line 1019 of /home/x/includes/database/database.inc).
Drush command terminated abnormally due to an unrecoverable error.     

field_university is just a simple field collection with a text field and a date field.

When I use the UI, I get a rollback issue:
DatabaseTransactionNoActiveException: in DatabaseConnection->rollback()

Any thoughts?

Edit: I've updated Entity API to the latest version and applied the patch here for EntityReference and am still getting Revision ID errors.

Devel Generate UI now crashes as follows:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'field_children_revision_id' cannot be null: INSERT INTO {field_data_field_children} (entity_type, entity_id, revision_id, bundle, delta, language, field_children_value, field_children_revision_id) 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); Array ( [:db_insert_placeholder_0] => field_collection_item [:db_insert_placeholder_1] => 68 [:db_insert_placeholder_2] => 68 [:db_insert_placeholder_3] => field_relationships [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 67 [:db_insert_placeholder_7] => ) in field_sql_storage_field_storage_write() (line 448 of /home/x/modules/field/modules/field_sql_storage/field_sql_storage.module).

And drush genc spits out the following:

WD field_collection_item: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'field_children_revision_id' cannot be null: INSERT INTO {field_data_field_children} (entity_type, entity_id, revision_id,  [error]
bundle, delta, language, field_children_value, field_children_revision_id) 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, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12,
:db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15), (:db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20,
:db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23); Array
(
    [:db_insert_placeholder_0] => field_collection_item
    [:db_insert_placeholder_1] => 78
    [:db_insert_placeholder_2] => 78
    [:db_insert_placeholder_3] => field_relationships
    [:db_insert_placeholder_4] => 0
    [:db_insert_placeholder_5] => und
    [:db_insert_placeholder_6] => 75
    [:db_insert_placeholder_7] => 
    [:db_insert_placeholder_8] => field_collection_item
    [:db_insert_placeholder_9] => 78
    [:db_insert_placeholder_10] => 78
    [:db_insert_placeholder_11] => field_relationships
    [:db_insert_placeholder_12] => 1
    [:db_insert_placeholder_13] => und
    [:db_insert_placeholder_14] => 76
    [:db_insert_placeholder_15] => 
    [:db_insert_placeholder_16] => field_collection_item
    [:db_insert_placeholder_17] => 78
    [:db_insert_placeholder_18] => 78
    [:db_insert_placeholder_19] => field_relationships
    [:db_insert_placeholder_20] => 2
    [:db_insert_placeholder_21] => und
    [:db_insert_placeholder_22] => 77
    [:db_insert_placeholder_23] => 
)
 in field_sql_storage_field_storage_write() (line 448 of /home/x/modules/field/modules/field_sql_storage/field_sql_storage.module).
WD php: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'field_children_revision_id' cannot be null: INSERT INTO {field_data_field_children} (entity_type, entity_id, revision_id, bundle, delta,     [error]
language, field_children_value, field_children_revision_id) 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, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13,
:db_insert_placeholder_14, :db_insert_placeholder_15), (:db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20, :db_insert_placeholder_21,
:db_insert_placeholder_22, :db_insert_placeholder_23); Array
(
    [:db_insert_placeholder_0] => field_collection_item
    [:db_insert_placeholder_1] => 78
    [:db_insert_placeholder_2] => 78
    [:db_insert_placeholder_3] => field_relationships
    [:db_insert_placeholder_4] => 0
    [:db_insert_placeholder_5] => und
    [:db_insert_placeholder_6] => 75
    [:db_insert_placeholder_7] => 
    [:db_insert_placeholder_8] => field_collection_item
    [:db_insert_placeholder_9] => 78
    [:db_insert_placeholder_10] => 78
    [:db_insert_placeholder_11] => field_relationships
    [:db_insert_placeholder_12] => 1
    [:db_insert_placeholder_13] => und
    [:db_insert_placeholder_14] => 76
    [:db_insert_placeholder_15] => 
    [:db_insert_placeholder_16] => field_collection_item
    [:db_insert_placeholder_17] => 78
    [:db_insert_placeholder_18] => 78
    [:db_insert_placeholder_19] => field_relationships
    [:db_insert_placeholder_20] => 2
    [:db_insert_placeholder_21] => und
    [:db_insert_placeholder_22] => 77
    [:db_insert_placeholder_23] => 
)
 in field_sql_storage_field_storage_write() (line 448 of /home/x/modules/field/modules/field_sql_storage/field_sql_storage.module).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'field_children_revision_id' cannot be null: INSERT INTO {field_data_field_children} (entity_type, entity_id, revision_id, bundle, delta, language, field_children_value, field_children_revision_id) 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, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15), (:db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20, :db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23); Array
(
    [:db_insert_placeholder_0] => field_collection_item
    [:db_insert_placeholder_1] => 78
    [:db_insert_placeholder_2] => 78
    [:db_insert_placeholder_3] => field_relationships
    [:db_insert_placeholder_4] => 0
    [:db_insert_placeholder_5] => und
    [:db_insert_placeholder_6] => 75
    [:db_insert_placeholder_7] => 
    [:db_insert_placeholder_8] => field_collection_item
    [:db_insert_placeholder_9] => 78
    [:db_insert_placeholder_10] => 78
    [:db_insert_placeholder_11] => field_relationships
    [:db_insert_placeholder_12] => 1
    [:db_insert_placeholder_13] => und
    [:db_insert_placeholder_14] => 76
    [:db_insert_placeholder_15] => 
    [:db_insert_placeholder_16] => field_collection_item
    [:db_insert_placeholder_17] => 78
    [:db_insert_placeholder_18] => 78
    [:db_insert_placeholder_19] => field_relationships
    [:db_insert_placeholder_20] => 2
    [:db_insert_placeholder_21] => und
    [:db_insert_placeholder_22] => 77
    [:db_insert_placeholder_23] => 
)
 in field_sql_storage_field_storage_write() (line 448 of /home/x/modules/field/modules/field_sql_storage/field_sql_storage.module).
Drush command terminated abnormally due to an unrecoverable error.    

My best guess is that this is an issue introduced with the addition of revision support; might try the stable version of Field Collection instead, see if it's still affected.

steven.wichers’s picture

I also am having an issue with revisions when generating content. The problems I am having are similar to what is mentioned in #1827008: Devel generate does not save a generated field collection entirely. The difference would be that I have no translation modules enabled.

Looking at the database shows that everything gets generated correctly with the exception of the revision ID being set. If I manually set the revision ID to the correct number the generated field collections will show up. I am working around this problem by generating the content and then running:

UPDATE field_data_field_{name} SET field_{name}_revision_id = field_{name}_value WHERE field_{name}_revision_id IS NULL;
UPDATE field_revision_field_{name} SET field_{name}_revision_id = field_{name}_value WHERE field_{name}_revision_id IS NULL;

After running this code and clearing cache the collections will appear.

mgifford’s picture

Issue summary: View changes

This would be a nice feature...

joshf’s picture

Status: Needs work » Needs review
StatusFileSize
new473 bytes

The attached patch fixes the revision id issue for me.

wizonesolutions’s picture

Hrm, it was probably not the best to reopen this closed issue (it's confusing). However, it did fix the issue. +1. mgifford, did you test the patch? If so we can probably RTBC.

mgifford’s picture

@wizonesolutions I haven't had a chance to test it unfortunately. I did briefly in SimplyTest.me and it still applies even though there's a new release from 3 months ago.

I'm not going to have time to test it..

AlxVallejo’s picture

Status: Needs review » Reviewed & tested by the community

Tested the revision ID patch and it works, even with nested field collections. Nice work guys.

  • jmuzz committed 52b09be on 7.x-1.x authored by joshf
    #1236402 by joshf: Revision fix for devel generate.
    
jmuzz’s picture

Status: Reviewed & tested by the community » Fixed

Great. If there's any further problems with it please open a new issue.

Status: Fixed » Closed (fixed)

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

delacosta456’s picture

hi
please is this included in latest version of field collection?