When adding a computed value and selecting "store to database" -option with a default value, the SQL code breaks. I don't know why this is, but always when using a default value, the new field value would not be saved at the content_type_whatever -column, where I think it should. No checkboxes were selected except for the "display value" -checkbox.

After the faulty insert code, all the column alter's and update's break because there is no column to be updated.

Comments

cheater’s picture

Title: Default value breaks SQL » SQL error on saving field settings
Priority: Normal » Critical

I experience the same problem.

I tried a fresh, minimal installation of Drupal 5.7, CCK, and SimpleMenu, Views.

the error displayed is:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cftest_defaultvalue' at line 1 query: ALTER TABLE dcfcontent_type_cftest ADD COLUMN field_cftest_sum_value varchar(50) default cftest_defaultvalue in C:\apache_root\drupal-cftest\includes\database.mysqli.inc on line 151.

What I did:


  1. set up the site and enable cck, computed field, views, and simplemenu modules. Site uses its own database.
  2. create new content type
  3. add integer fields number1 and number2 to that content type
  4. add computed field to content type. the settings are mostly default:

    • computed code is &node_field[0]['value'] = 2;
    • display this field turned on
    • store using the database settings below on, with data type varchar, length 50, default value cftest_defaultvalue, sortable on, not null off (so, mostly default)

  5. click save field settings
  6. the resultant page shows the error.

I find this a critical bug and labeled it as such.
Is there a workaround, and if so, what is it?
If there is a way to fix it, I would be willing to participate in fixing the issue, given a hand with this from one of the developers familiar with computed field.
Walterh’s picture

I have a same kind of problem. When I import nodes (using the Node Import module) I get SQL-errors on all the computed field, while they always worked fine for me. When I make new nodes by hand, the problem doesn't occur

problem solved, the problem was not related to the computed fields

deekayen’s picture

Status: Active » Closed (fixed)