Now that value types are not initialized automatically, it would be useful to be able to specify default values for properties (both value type and reference type) in the entity declaration, which are executed automatically on construction. There are many cases where initialization depends on the context, but there are enough where a simple default value is needed.

entity Answer {
graded :: Bool (default = false)
}

Submitted by Eelco Visser on 11 March 2010 at 21:17

On 12 March 2010 at 09:43 Danny Groenewegen commented:

Int, Bool, String (%2BString equivalent types such as WikiText), Float are still initialized automatically to 0,false,"",0.0 respectively.

This doesn't work for entities that are already in the database, and a property/column is added to the schema using update database mode. You could write a function in WebDSL that fixes these properties (e.g. with an init on the edit page), or fix it in the database with an update query.


On 12 March 2010 at 09:54 Eelco Visser commented:

But I want to be able to express other initial values than the default ones, and I also want to initialize entity type properties.


On 12 March 2010 at 10:01 Danny Groenewegen commented:

I didn't close the issue, I was commenting on "Now that value types are not initialized automatically". I also think an annotation for default values is a nice feature.


On 8 June 2010 at 13:59 Danny Groenewegen closed this issue.

On 8 June 2010 at 13:59 Danny Groenewegen commented:

default annotation added in revision 3967

Log in to post comments