NULL as default value

A place for users and developers of the Xataface to discuss and receive support.

Postby 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.
alexst
 
Posts: 7
Joined: Wed Dec 31, 1969 5:00 pm

Postby 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
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby alexst » Thu Feb 22, 2007 5:19 pm

Thanks, will try it and post the results.
alexst
 
Posts: 7
Joined: Wed Dec 31, 1969 5:00 pm

Postby 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.
woolf
 
Posts: 1
Joined: Thu Oct 08, 2009 4:15 am

Postby 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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 20 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved