Commits

chunquedong committed f715f21 Draft

Add make constructor for Serialization

Comments (0)

Files changed (5)

slanData/fan/CField.fan

   ** hint to build index on this field
   const Bool? indexed
 
-  new make(Str name, Type type, Int index, |This|? f := null)
+  new make(|This| f) { f(this) }
+
+  new makeNew(Str name, Type type, Int index, |This|? f := null)
   {
     this.name = name
     this.type = type

slanData/fan/Record.fan

 @Serializable
 class Record
 {
+  @Transient
   Schema schema { private set }
+
   private Obj?[] values
 
   new make(Schema s, Obj?[]? vals := null)

slanData/fan/Schema.fan

   ** auto generate the key
   const Bool autoGenerateId
 
-  new make(Str name, CField[] fields, Int idIndex := -1, Bool autoGenerateId := false)
+  new make(|This| f) { f(this) }
+
+  new makeNew(Str name, CField[] fields, Int idIndex := -1, Bool autoGenerateId := false)
   {
     this.columns = fields
     this.name = name

slanOrm/fan/model/OField.fan

   **
   ** if the name is null, will use field name
   **
-  new make(Field field, Int index, Str? name := null, |This|? f := null)
-    : super(name ?: field.parent.name + "_" + field.name, field.type, index, f)
+  new makeNew(Field field, Int index, Str? name := null, |This|? f := null)
+    : super.makeNew(name ?: field.parent.name + "_" + field.name, field.type, index, f)
   {
     this.field = field
   }

slanOrm/fan/model/OSchema.fan

   ** Entity type
   const Type type
 
-  new make(Type type, Str name, CField[] fields, Int idIndex := -1, Bool autoGenerateId := false)
-    : super(name, fields, idIndex, autoGenerateId)
+  new makeNew(Type type, Str name, CField[] fields, Int idIndex := -1, Bool autoGenerateId := false)
+    : super.makeNew(name, fields, idIndex, autoGenerateId)
   {
     this.type = type
     if (!type.hasFacet(Serializable#))