global variable initialization creates duplicate instances when referring to other global variables
global variable initialization creates duplicate instances when referring to other global variables
entity User{ name : String password : Secret } var alice := User{ name := "alice" password := "test" } entity Document{ title : String text : String author : User } var d0 := Document{ title := "First Document" text := "This is the first text." author := alice }
results in two User instances
related to https://yellowgrass.org/issue/WebDSL/450
workaround, initialize data with init block:
Submitted by Danny Groenewegen on 15 February 2016 at 15:56var alice:User //can also be moved into init if it doesn't need global reference init{ alice :=User{ name := "alice" password := ("test" as Secret).digest() }.save(); Document{ title := "First Document" text := "This is the first text." author := alice }.save(); }
Log in to post comments