Download & Extend

Field format columns cannot be NULL

Project:TableField
Version:7.x-2.0-alpha4
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community

Issue Summary

The field_fieldname_format columns in tables:

  • field_data_field_fieldname
  • field_revision_field_fieldname

Are created without accepting NULL values. On submission of a new node, Drupal complains that these columns cannot be NULL (presumably it attempts to INSERT NULL in these fields) and does not save the node.

Removing the constraint from the database table definitions manually, solves the problem... but I do not know if it creates any more. What is the purpose of that column?

Comments

#1

Something does go wrong, but I am not sure if it is related or not. On an AJAX update of the edit page for a node type which includes a TableField I get this error:

Notice: Undefined index: tablefield in tablefield_field_widget_form() (line 243 of drupalpath/sites/all/modules/tablefield/tablefield.module).

and I am unable to submit.

Pressing the "Rebuild table" button fixes the problem. If you think it is unrelated to this issues, I am happy to submit it as a separate bug.

#2

Apologies for the multiple postings, I think this comment will be helpful:

When choosing "Filtered html" as the format type the field_fieldname_format column is no longer NULL and the submission happens without a problem. Therefore I think the problem is only encountered when "Plain text" is selected. Switching to "Filtered html" solves the problem. Switching back to "Plain text" brings the problem back.

#3

Cool, that does help. I don't have much free time today, but I suspect that it has something to do with the machine names for input filters and perhaps some changes in the release candidates.

If you come up with a fix, please submit a patch. Otherwise, I'll try to fix on my train ride home.

Thx!

#4

Status:active» needs review

Ok, here's a patch that defines the format column without the not null definition. This won't fix already created fields, but will correctly define new ones.

Let me know if that seems sufficient. I'll also work on an update hook that repairs pre-existing fields.

AttachmentSize
tablefield-1003382-4.patch 560 bytes

#5

Here's the patch for the hook_update_n - this will fix any pre-existing fields created with the bad schema.

AttachmentSize
tablefield-install-repair-1003382-5.patch 1.04 KB

#6

Status:needs review» reviewed & tested by the community

Happy New Year and apologies for the delay. This patch appears to work. It corrected the existing records and allows switching of the filter. Thank you very much.