Skip to content

Commit 64b95ea

Browse files
committed
Added support for String[] and Integer[] arrays in the Field class
1 parent 8794f92 commit 64b95ea

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

Diff for: src/javaxt/orm/Field.java

+15-9
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ protected Field(String name, String type){
3030
this.name = name;
3131
this.columnName = Utils.camelCaseToUnderScore(name);
3232

33+
//Set columnType and tweak type as needed
3334
if (type.equalsIgnoreCase("int")){
34-
type = "integer";
35+
type = "Integer";
36+
columnType = "integer";
37+
}
38+
else if (type.equalsIgnoreCase("int[]")){
39+
type = "Integer[]";
40+
columnType = "integer array";
3541
}
3642
else if (type.equalsIgnoreCase("long")){
3743
columnType = "bigint";
@@ -44,9 +50,13 @@ else if (type.equalsIgnoreCase("decimal") || type.equalsIgnoreCase("numeric")){
4450
type = "BigDecimal";
4551
columnType = "numeric";
4652
}
47-
else if (type.equalsIgnoreCase("text") || type.equalsIgnoreCase("string")){
48-
type = "string";
49-
columnType = "text";
53+
else if (type.equalsIgnoreCase("text") || type.equalsIgnoreCase("string") || type.equalsIgnoreCase("password")){
54+
type = "String";
55+
columnType = "varchar"; //varchar without the length specifier and text are equivalent
56+
}
57+
else if (type.equalsIgnoreCase("text[]") || type.equalsIgnoreCase("string[]")){
58+
type = "String[]";
59+
columnType = "varchar array"; //same as "text array"
5060
}
5161
else if (type.equalsIgnoreCase("char")){
5262
type = "string";
@@ -74,17 +84,13 @@ else if (type.equalsIgnoreCase("geometry")){
7484
type = "Geometry";
7585
columnType = "geometry(GeometryZ)";
7686
}
77-
else if (type.equalsIgnoreCase("password")){
78-
//type = "String";
79-
columnType = "text";
80-
}
8187
else{ //Model?
8288

8389

8490
if (type.endsWith("[]")){ //Array of models
8591

8692
String modelName = type.substring(0, type.length()-2);
87-
type = "ArrayList<" + modelName + ">";
93+
type = "ArrayList<" + Utils.capitalize(modelName) + ">";
8894

8995
}
9096
else{ //Single model

0 commit comments

Comments
 (0)