Hello,

I receive the following error for "emfield video field" when I save a node:

user warning: Column 'field_video_embed_version' cannot be null query: UPDATE content_field_video_embed SET vid = 7, nid = 7, field_video_embed_embed = NULL, field_video_embed_value = NULL, field_video_embed_provider = NULL, field_video_embed_data = 'N;', field_video_embed_version = NULL, field_video_embed_duration = NULL WHERE vid = 7 in D:\DEVELOPMENT\xampp\www\mysite\sites\all\modules\cck\content.module on line 1213.

As the error describes this message only to appears if the video field is empty.
I use a fresh Drupal 6.14 installation with CCK 2.5. I didn't hack the database or anything else.

Help is much appreciated.
Please let me know if you need more information.

Kind regards,
Stefan

CommentFileSizeAuthor
#18 help.jpg100.58 KBmarta_yo
#5 phpMyAdmin.png21.5 KBdesign.er
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

design.er’s picture

BTW: I use YouTube services in this field.

Ashford’s picture

Use phpMyAdmin to edit the fields. Click to check mark the box labeled "NULL". Do not change the default values.

Database Table & fields
content_field_video -- field_video_version, field_video_duration
content_field_audio -- field_audio_version

design.er’s picture

Hi Ashford, thank you for your quick response.
Sorry but I'm afraid I don't understand what you mean. Please can you describe what to do with the fields in phpMyAdmin?
Sorry for the circumstances.

TrevorG’s picture

Category: support » bug

Hi I fixed this.

Basically, as he said, go to phpMyAdmin

  1. Go to the table that has your drupal install on it.
  2. Go to the table that has the content type that you are experiencing issues with the emfield with.
  3. Go to the rows with the emfield... there should be a total of six variations of the emfield ending in _embed, _value, _provider, _data, _ version, and _duration.
  4. Change _version and _duration 's NULL column to null. Don't change the value (which should be 0).
  5. That should fix it. You'll probably have to repeat for each content type, but I only use it for one so far.

I changed this to a bug because I don't know how it can't be. I had a clean install of emfield, tried the dev even and it wasn't fixed. Don't know how more users aren't having issues with this. By the way, great module otherwise, thank you!

design.er’s picture

FileSize
21.5 KB

Sorry for the ultra delayed answer.
Attached is a screenshot if my phpMyAdmin. Please can you tell me if my phpMyAdmin is correct - I neither see a "NULL" checkbox (from comment #2) nor a field where I could replace "NULL" with "null" - only an integer field with the 0 - for the fields _version and _duration.
Maybe you could also post a screenshot with your values.

And, should I replace this values for every node extra?

Thanks a lot for your help.

shilpawaidya’s picture

Thanks a lot TrevorG.. I had the same issue and you instructions helped me solve it.

schnippy’s picture

Version: 6.x-1.11 » 6.x-1.18

I had the same issue using 6.x-1.18. The content wasn't saving when the video value was empty and this error message was in the log file:

Column field_fieldname_video_value cannot be null query: ...

I fixed this by altering the columns directly in MySQL (similar to the phpMyAdmin solutions above):

alter table content_type_typename modify `field_fieldname_video_value` varchar(255) default '';

I had to do this for _value and _provider for my content to save again. In the module code, is this where this 'NOT NULL' setting is set for the database field:

emfield.cck.inc: lines 19-22

    'value' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'not null' => FALSE, 'sortable' => TRUE),
    // This is the actual provider used;
    // matches up with the specific provider.inc file.
    'provider' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'not null' => FALSE, 'sortable' => TRUE),

Is it as simple as changing the settings to keep this from re-occuring or am I missing some other implication from allowing null data for an empty field? Is there a database update already for this?

skizzo’s picture

I am experiencing a similar error in 6.x-1.18. It happens when creating a node (emf Picasa image + emf Youtube video) which includes the image, while not including any video. Apparently the node creation completes successfully, the only side effect being the watchdog warning. Can I safely disregard this warning?

user warning: Column 'field_emb_videofield_00_version' cannot be null query: UPDATE content_field_emb_videofield_00 SET vid = 16486, nid = 16486, field_emb_videofield_00_embed = NULL, field_emb_videofield_00_value = NULL, field_emb_videofield_00_provider = NULL, field_emb_videofield_00_data = NULL, field_emb_videofield_00_version = NULL, field_emb_videofield_00_duration = NULL WHERE vid = 16486 in /var/www/drupal/sites/all/modules/cck/content.module on line 1213.

Anonymous’s picture

Version: 6.x-1.18 » 6.x-1.19

The issue still occurs in 6.x-1.19
The above-mentioned solutions with phpMyAdmin worked.

Cyberwolf’s picture

Subscribing.

liquidcms’s picture

i think for the D6 module the CCK "schema" for this field is defined correctly to allow null (see note below)

but, on my site at least where the D6 db was converted from a D5 site the mysql field is not set to allow null - however it also has a mysql default set as "empty string" (for D6 default is set to null).. and it therefore works correctly

from this i would have to assume that the D5 code for this field handled the no value case by letting mysql simply insert its empty string. in the d6 version of the code possibly the module inserts a null via php and therefore mysql tries to insert a null - which in a table originally created in D6 is fine as it accepts nulls; but in a D6 table converted from D5 it doesn't

hope that all made sense.

anyway.. solution above to manually allow for nulls should work.. but there should really be an update script to go through existing fields and set to allow for null.

ALSO... the D6 cck code for this field is a bit messed up. In emfield.cck.inc:

/**
 *  Helper function to consistantly define field columns.
 */
function _emfield_field_columns($field) {
  $columns = array(
    // This contains the original URL or embed code pre-parsing,
    // as entered by the user/editor.
    'embed' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE, 'not null' => FALSE, 'sortable' => TRUE),
    // This contains the code used by the provider to identify the media.
    'value' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'not null' => FALSE, 'sortable' => TRUE),
    // This is the actual provider used;
    // matches up with the specific provider.inc file.
    'provider' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'not null' => FALSE, 'sortable' => TRUE),
    // An array for any extra data required by this media,
    // such as unique thumbnail requirements or rss feed data.
    'data' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE, 'not null' => FALSE, 'sortable' => FALSE),
    // The version of the provider's data, as an integer. In general, this
    // number will be increased incrementally as changes to the API are
    // introduced, or the module introduces or requires new data.
    // Emfield uses this periodically in its updates.
    'version' => array('description' => t("The version of the provider's data."), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
  );

  // Allow other modules to add new columns.
  $columns = array_merge($columns, module_invoke_all('emfield_field_columns_extra', $field));

  return $columns;
}

of course the setting 'not null' to TRUE and then writing over it with FALSE doesn't make much sense.

i could provide patch but i am not sure i have latest rev of the module.. i'll check..

notfound_old’s picture

Had exactly the same problem, with 6.x-1.19 & postgres - unable to save node with "Query failed: ERROR: null value in column (...) violates not-null constraint in (...)" error messages in watchdog.

This helped:

ALTER TABLE content_type_ ALTER COLUMN field__video_version DROP NOT NULL;
ALTER TABLE content_type_ ALTER COLUMN field__video_duration DROP NOT NULL;

Balbo’s picture

#4 worked for me.

NicolasH’s picture

I needed something more robust than changing this manually, since I run an upgrade script every night from D5 to D6. It seems the update (6005) in emfield.install doesn't really attempt to change existing NULL settings of the different columns.

liquidcms' observations in #11 make sense, would be good to get a module maintainer's view on this.

Anyway, in my case I run this to change the settings throughout the DB for any instance of emfield video:

include_once(drupal_get_path('module', 'content') .'/content.install');
include_once(drupal_get_path('module', 'content') .'/includes/content.admin.inc');

  foreach (content_types_install() as $type_name => $type_fields) {
    foreach ($type_fields as $field) {
      if (in_array($field['module'], array('emvideo'))) {
        
        $new_db_info = content_database_info($field);
        $new_table = $new_db_info['table'];

        foreach ($field['columns'] as $column => $attributes) {
          if (in_array($column, array('embed', 'value', 'provider', 'data'))) {
            $attributes['not null'] = FALSE;
            $db_field = $field['field_name'] .'_'. $column;
            db_change_field($ret, $new_table, $db_field, $db_field, $attributes);
          }
        }
      }
    }
  }

It's array('emvideo') because you can add other emfield types, but I haven't needed that and don't know the implications. You can run this as a snippet in Devel, but it would be best as an update in an .install file, in which case you don't need the includes at the top.

I would like to know whether this works for others...pls don't run this on a production site.

skizzo’s picture

Version: 6.x-1.19 » 6.x-1.x-dev

Changing Version to 6.x-1.x-dev
(problem confirmed in 6.x-1.26)

Iho Tea’s picture

Confirm the problem in 6.x-2.4...
why? ;)

marta_yo’s picture

FileSize
100.58 KB

#4 Worked for me!
#5, maybe it's too late, but your problem is that you are editing the fields inside the table, you must edit the table estructure. See the screen capture attached.

arthurf’s picture

I believe this is an issue caused by mysql versions. If you look at http://bugs.mysql.com/bug.php?id=39265, it appears that versions 5.1 - 5.1.31 change the way that NULL works with an update when the column is defined as NOT NULL. I tested on 5.0.51a which worked correctly. 5.1.31 had the error described in this thread. 5.1.44 worked correctly.

The fix for this would be to change the column described in _emfield_field_columns(). I was able to confirm this by doing:

ALTER TABLE {content_type_video} CHANGE `field_video_version` `field_video_version` INT( 10 ) NULL DEFAULT '0' 

Obviously replace content and field names with the appropriate ones on your system. I'm a bit surprised this has not happened for more modules, but I'm pretty certain that the fix is correct because the error is only thrown on update and only for the mysql versions described here.

electblake’s picture

Thanks @TrevorG, worked like a charm :)

Rade’s picture

#4 worked like a charm!
Thanks!

pcorbett’s picture

Version: 6.x-1.x-dev » 6.x-2.4

Experienced same issue discussed in MySQL 5.1.41-3ubuntu12.3. Manually ran

ALTER TABLE {content_type_[my_content_type]} CHANGE `field_[my_content_type]_video_version` `field_[my_content_type]_video_[version, provider, value, etc.]` INT( 10 ) NULL DEFAULT '0';

to allow NULLs in respective columns. Works as reported above. I had also tried upgrading to 6.x-2.x-dev and experienced the same issue.

kriskhaira’s picture

#4 worked for me with 6.x-2.x-dev. Thanks!

ShaneOnABike’s picture

Wow this suddenly appeared out of nowhere for us I think since we upgraded the module. I can confirm this is an issue although I had to use the following to make the approriate changes.

ALTER TABLE content_type_film MODIFY field_trailer_url_provider varchar(255) NULL; 

And the same for all the other not null values.

We should really fix this it's pretty serious?

ShaneOnABike’s picture

One thing that I would note though is now when I save fields empty ones are saved. So when using lightbox with this it always renders a link... probably a bug in lightbox so I'll report there but I thought I would mention it anyway.

wojtha’s picture

Version: 6.x-2.4 » 6.x-2.x-dev
Priority: Normal » Major

#22 Worked for me at 6.x-2.5. Thanks.

Seems that the same problem also in the dev version according to #23.

Marking as major, since it breaks node update - other fields aren't updated.

CMStom’s picture

#4 worked perfectly! Thanks for sharing!

marcoBauli’s picture

#4, #5 and #18 helped, thanks

ShaneOnABike’s picture

Maybe we should add this to the install?