Skip to content

Commit ea30b4c

Browse files
committed
Improved support for "defaults"
1 parent 4a0716d commit ea30b4c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/javaxt/orm/Model.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ protected Model(String modelName, JSONObject modelInfo, String packageName, Hash
7474
//Create field and update the fields array
7575
Field field = new Field(name, type, this);
7676
addConstraints(field, f.toJSONObject());
77+
Object defaultValue = f.get("default").toObject();
78+
field.setDefaultValue(defaultValue);
7779
this.fields.add(field);
7880
}
7981
}
@@ -136,7 +138,8 @@ protected Model(String modelName, JSONObject modelInfo, String packageName, Hash
136138
JSONArray defaultValues = modelInfo.get("defaults").toJSONArray();
137139
if (defaultValues!=null){
138140
for (JSONValue d : defaultValues){
139-
String fieldName = d.get("name").toString();
141+
String fieldName = d.get("field").toString();
142+
if (fieldName==null) fieldName = d.get("name").toString();
140143

141144
for (Field field : fields){
142145
if (field.getName().equals(fieldName)){

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy