Define default values for properties in entity declaration (1)
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 {
Submitted by Eelco Visser on 11 March 2010 at 21:17
graded :: Bool (default = false)
}
Issue Log
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.
But I want to be able to express other initial values than the default ones, and I also want to initialize entity type properties.
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.
default annotation added in revision 3967
Log in to post comments