After upgrade from 6.x-1.0 to 6.x-1.1 I'm getting this error when I leave the view field empty:
User warning: Column 'field_promoblock_view_vname' cannot be null query: content_write_record INSERT INTO ... etc.
I believe it is because of following change:
@@ viewfield_select_process($element, $edit, $form_state, $form) {
- '#default_value' => $element['#default_value']['vname'],
+ '#default_value' => isset($element['#default_value']['vname']) ? $element['#default_value']['vname'] : NULL,
Because in database definition, you don't allow vname to be NULL:
@@ function viewfield_field_settings($op, $field) {
case 'database columns':
return array(
// Views requires at least 96 chars for the view name and display, plus
// we need 1 for our delimiter. Round up to a common value of 128.
'vname' => array('type' => 'varchar', 'not null' => FALSE, 'length' => 128),
'vargs' => array('type' => 'varchar', 'not null' => FALSE, 'length' => 255),
);
Comments
Comment #1
keithm commentedThe line in viewfield_select_process looks suspect to me also, but I can't reproduce your problem. I've just tried to break 6.x-1.0 and 6.x-1.x by leaving the view name field empty in a variety of ways, and I haven't been able to generate your error at all. Can you please provide steps to reproduce the problem you're seeing? Do you have any views enabled? Thanks.
Comment #2
wojtha commentedI experience that during both Insert and Update. And yes I have several views enabled for the field.
It might be dependent on the used database/version or on specific setup. But in my case vname table column had NOT NULL property and if the viewfield was empty, I found NULL in the error query. In the previous version was there empty string '' instead of NULL.
I'm using MySQL 5.0.51a, Debian Lenny 64bit, Drupal 6.20.
Comment #3
keithm commentedIn MySQL, your content type table (e.g., content_type_mytype) has a field_promoblock_view_vname'. That field's 'Null' property should be 'Yes' (or 1). (This is the same as 'not null' == 'FALSE'.) Is this setting correct in your database?
Comment #4
wojtha commentedNope I had "not null = TRUE" ~ NULL is disallowed. I changed NULL = NO to NULL = YES in the table when tried to fix the error yesterday.
So yesterday's config was:
Hmm, strange. I will try to create new field and will see what happend.
And I was wrong with Drupal version. I'm not using Drupal but Pressflow (6.20).
Comment #5
wojtha commentedHa I found the bug.
The bug is in the update function:
Comment #6
keithm commentedOK, I think I understand. New fields are being produced correctly but the schema upgrade process has a problem, so when you upgraded your database the 'Null' property was set incorrectly. Will you apply this patch and upgrade your database again please?
Comment #7
wojtha commentedBest way to fix it will be probably rename viewfield_update_6001() to 6002 and fix the not null to FALSE. So the update will run on all installation no matter if the installation upgraded with 6001 update or not.
Comment #8
keithm commentedI'll think about that but will you confirm that this change fixes your problem?
Comment #9
wojtha commentedNo it is not working if the 6001 is applied because of the length condition:
if ($vname_info['length'] < $new_length) {I tried to modify it to this:
if ($vname_info['length'] < $new_length || $vname_info['not null'] => TRUE) {But it doesn't work since in $vname_info contains values taken from Schema API and not real values from database schema. So I modify update to iterate over all fields. Alternate approach will be check for the real 'not null' schema property.
Comment #10
keithm commentedIn #8 I was asking if the patch fixed the problem if the whole conversion process was redone. In that case 6001 wouldn't have run yet.
The 6.x-2.x branch already has a update_6002() so it must be accounted for.
Comment #11
wojtha commentedNo I have it "right" in #9 but I generated a reverse patch... I was lazy to use git which I usually use for patches, so I used only Netbeans IDE and swap the directions accidentally.
It might be handy to add comment why 6002 is missing.
I can confirm that the both patches in #9 (reversed) and in #10 is working.
Comment #12
keithm commentedFixed in http://drupalcode.org/project/viewfield.git/commit/738e96f.
Comment #13
chrisada commentedI have already upgraded to 6.x-1.1 and am facing this problem. Could someone help point out how to fix my database? Thank you so much!
Comment #14
keithm commentedThis problem is fixed in the development release 6.x-1.x-dev. Please try that and report back if it fixes your problem. I want some confirmations that this fixes the problem before issuing a new general release.
Comment #15
chrisada commentedkeithm, sorry I just has the chance to response. I faced the issue on a live site, and had to take immediate action. The only thing I did was manually editing the few viewfield fields and set NULL to yes, and everything works. If the changes you made in 6.x-1.x-dev includes that, it should fix problem for those who had upgraded from 1.0 to 1.1.
I don't have a backup of the database from when the problem still exist, so, sorry I couldn't help test this directly.
Thanks
Comment #16
dargrego commentedI had similar problem and having upgraded 6.x-1.1 to the latest dev version, it disappeared, so it's working.
Thanks
Comment #17
stacysimpson commented@keithm, not sure if you are still looking for feedback on this thread, but we ran into this issue after upgrading to 6.x-1.1. The latest dev release, 6.x-1.x-dev (May 7 2011), resolved the issue after running DB update queries.
Comment #18
keithm commented@stacysimpson Glad to hear this. Thanks.
Comment #19
sgerbino commented6.x-1.x-dev also resolves the issue for my installation
Comment #20
roball commentedI was also hit by this bug after upgrading from 1.0 to 1.1. Content that could be created without any problems under 1.0 may no longer be created under 1.1 - thus I am considering this bug as critical. Upgrading to 6.x-1.x-dev (2011-May-31) fixed the problem. IMO, 1.2 should be released asap. Thanks for consideration.
Comment #21
nterbogt commentedI'm also experiencing this issue and would like to see a new release sooner rather than later. It appears to have been fixed since the end of May, and has been two months.
In the meantime I'm planning to roll back to 1.0. I generally don't use development branches on my production servers.
Comment #22
roball commentedI have opened #1229576: Please release Viewfield 6.x-1.2 to request a new official 6.x-1.x release.