NULL as default value

Archived from the Xataface Users forum.

alexst — Wed Feb 21, 2007 11:59 am

I have the following field:

Some\_long\_field\_name tinyint(1) default NULL,

and the following fileds.ini entry

widget:type = “select”
vocabulary = Score

Dataface doesn’t seem to pick up on the NULL default setup trough mysql. tried adding “Default = NULL” - didn’t work; adding “NULL = N/A” and “Default = N/A” in valuelist.ini didn’t work either. It always defaults to 0 which is a problem for me since I am using this filed in AVERAGE calculations.


shannah — Thu Feb 22, 2007 2:07 pm

Hi Alex,

Good point on this. I’ll look into this for a future release.
In the mean time, you can use afterSave() triggers to correct this. Just have a special value in your valuelist that you want to be null, test for this in afterSave() and update the record accordingly.

-Steve


alexst — Thu Feb 22, 2007 5:19 pm

Thanks, will try it and post the results.


woolf — Thu Oct 08, 2009 4:18 am

Is there already a solution? I have the same problem, as I have an foreign key constraint on this field and 0 is not a foreign key. I tried to set the value in the function beforeInsert but NULL is handled as a string.


shannah — Thu Oct 08, 2009 7:17 am

The fix for this is in subversion. If you have the latest Dataface/Table.php and Dataface/Serializer.php it should fix this problem.

http://weblite.ca/svn/dataface/core/trunk

-Steve