@@ -1062,7 +1062,7 @@ else if (join != null){
10621062
10631063 Set <Entry <String , Object >> set = joinMap == null ? null : joinMap .entrySet ();
10641064 if (set == null || set .isEmpty ()) {
1065- Log .e (TAG , "doJoin set == null || set.isEmpty() >> return null;" );
1065+ Log .e (TAG , "onJoinParse set == null || set.isEmpty() >> return null;" );
10661066 return null ;
10671067 }
10681068
@@ -1092,7 +1092,7 @@ else if (join != null){
10921092
10931093 int index = path .indexOf ("/" );
10941094 if (index < 0 ) {
1095- throw new IllegalArgumentException (JSONRequest .KEY_JOIN + ":value 中value不合法 !"
1095+ throw new IllegalArgumentException (JSONRequest .KEY_JOIN + ":value 中 value 值 " + path + " 不合法 !"
10961096 + "必须为 &/Table0/key0,</Table1/key1,... 或 { '&/Table0/key0':{}, '</Table1/key1':{},... } 这种形式!" );
10971097 }
10981098 String joinType = path .substring (0 , index ); //& | ! < > ( ) <> () *
@@ -1105,37 +1105,70 @@ else if (join != null){
11051105 String tableKey = index < 0 ? null : path .substring (0 , index ); //User:owner
11061106 apijson .orm .Entry <String , String > entry = Pair .parseEntry (tableKey , true );
11071107 String table = entry .getKey (); //User
1108+ if (StringUtil .isName (table ) == false ) {
1109+ throw new IllegalArgumentException (JSONRequest .KEY_JOIN + ":value 中 value 的 Table 值 " + table + " 不合法!"
1110+ + "必须为 &/Table0/key0,</Table1:alias1/key1,... 这种形式!且 Table0 必须满足大写字母开头的表对象英文单词 key 格式!" );
1111+ }
1112+
11081113 String alias = entry .getValue (); //owner
1109- String key = StringUtil .isEmpty (table , true ) ? null : path .substring (index + 1 );//id@
1110- if (StringUtil .isEmpty (key , true )) {
1111- throw new IllegalArgumentException (JSONRequest .KEY_JOIN + ":value 中value不合法!"
1112- + "必须为 &/Table0/key0,</Table1/key1,... 这种形式!" );
1114+ if (StringUtil .isNotEmpty (alias , true ) && StringUtil .isName (alias ) == false ) {
1115+ throw new IllegalArgumentException (JSONRequest .KEY_JOIN + ":value 中 value 的 alias 值 " + alias + " 不合法!"
1116+ + "必须为 &/Table0/key0,</Table1:alias1/key1,... 这种形式!且 Table:alias 的 alias 必须满足英文单词变量名格式!" );
11131117 }
1118+
1119+ String key = StringUtil .isEmpty (table , true ) ? null : path .substring (index + 1 );//id@
11141120
11151121 //取出Table对应的JSONObject,及内部引用赋值 key:value
1116- tableObj = request .getJSONObject (tableKey );
1122+ try {
1123+ tableObj = request .getJSONObject (tableKey );
1124+ }
1125+ catch (Exception e2 ) {
1126+ throw new IllegalArgumentException (JSONRequest .KEY_JOIN + ":'" + path + "' 对应的 " + tableKey + ":value 中 value 类型不合法!必须是 {} 这种 JSONObject 格式!" + e2 .getMessage ());
1127+ }
1128+
11171129 targetPath = tableObj == null ? null : tableObj .getString (key );
11181130 if (StringUtil .isEmpty (targetPath , true )) {
1119- throw new IllegalArgumentException ("/" + path + ":value 中value必须为引用赋值的路径 '/targetTable/targetKey' !" );
1131+ throw new IllegalArgumentException ("/" + path + ":value 中 value 值 " + targetPath + " 不合法!必须为引用赋值的路径 '/targetTable/targetKey' !" );
11201132 }
11211133
11221134 //取出引用赋值路径targetPath对应的Table和key
11231135 index = targetPath .lastIndexOf ("/" );
11241136 targetKey = index < 0 ? null : targetPath .substring (index + 1 );
1125- if (StringUtil .isEmpty (targetKey , true ) ) {
1126- throw new IllegalArgumentException ("/" + path + ":'/targetTable/targetKey' 中targetKey不能为空 !" );
1137+ if (StringUtil .isName (targetKey ) == false ) {
1138+ throw new IllegalArgumentException ("/" + path + ":'/targetTable/targetKey' 中 targetKey 值 " + targetKey + " 不合法!必须满足英文单词变量名格式 !" );
11271139 }
11281140
11291141 targetPath = targetPath .substring (0 , index );
11301142 index = targetPath .lastIndexOf ("/" );
1131- targetTable = index < 0 ? targetPath : targetPath .substring (index + 1 );
1132-
1143+ String targetTableKey = index < 0 ? targetPath : targetPath .substring (index + 1 );
11331144
1145+ // 主表不允许别名
1146+ // apijson.orm.Entry<String, String> targetEntry = Pair.parseEntry(targetTableKey, true);
1147+ // targetTable = targetEntry.getKey(); //User
1148+ // if (StringUtil.isName(targetTable) == false) {
1149+ // throw new IllegalArgumentException("/" + path + ":'/targetTable/targetKey' 中 targetTable 值 " + targetTable + " 不合法!必须满足大写字母开头的表对象英文单词 key 格式!");
1150+ // }
1151+ //
1152+ // String targetAlias = targetEntry.getValue(); //owner
1153+ // if (StringUtil.isNotEmpty(targetAlias, true) && StringUtil.isName(targetAlias) == false) {
1154+ // throw new IllegalArgumentException("/" + path + ":'/targetTable:targetAlias/targetKey' 中 targetAlias 值 " + targetAlias + " 不合法!必须满足英文单词变量名格式!");
1155+ // }
1156+
1157+ targetTable = targetTableKey ; // 主表不允许别名
1158+ if (StringUtil .isName (targetTable ) == false ) {
1159+ throw new IllegalArgumentException ("/" + path + ":'/targetTable/targetKey' 中 targetTable 值 " + targetTable + " 不合法!必须满足大写字母开头的表对象英文单词 key 格式!" );
1160+ }
1161+
11341162 //对引用的JSONObject添加条件
1135- targetObj = request .getJSONObject (targetTable );
1163+ try {
1164+ targetObj = request .getJSONObject (targetTableKey );
1165+ }
1166+ catch (Exception e2 ) {
1167+ throw new IllegalArgumentException ("/" + path + ":'/targetTable/targetKey' 中路径对应的 '" + targetTableKey + "':value 中 value 类型不合法!必须是 {} 这种 JSONObject 格式!" + e2 .getMessage ());
1168+ }
1169+
11361170 if (targetObj == null ) {
1137- throw new IllegalArgumentException (targetTable + "." + targetKey
1138- + ":'/targetTable/targetKey' 中路径对应的对象不存在!" );
1171+ throw new IllegalArgumentException ("/" + path + ":'/targetTable/targetKey' 中路径对应的对象 '" + targetTableKey + "':{} 不存在或值为 null !必须是 {} 这种 JSONObject 格式!" );
11391172 }
11401173
11411174 tableObj .put (key , tableObj .remove (key )); //保证和SQLExcecutor缓存的Config里where顺序一致,生成的SQL也就一致
@@ -1147,11 +1180,16 @@ else if (join != null){
11471180 j .setJoinType (joinType );
11481181 j .setTable (table );
11491182 j .setAlias (alias );
1150- j .setTargetName (targetTable );
1183+ j .setTargetTable (targetTable );
1184+ // j.setTargetAlias(targetAlias);
11511185 j .setTargetKey (targetKey );
11521186 j .setKeyAndType (key );
11531187 j .setRequest (getJoinObject (table , tableObj , key ));
11541188 j .setOuter ((JSONObject ) e .getValue ());
1189+
1190+ if (StringUtil .isName (j .getKey ()) == false ) {
1191+ throw new IllegalArgumentException (JSONRequest .KEY_JOIN + ":value 中 value 的 key@ 中 key 值 " + j .getKey () + " 不合法!必须满足英文单词变量名格式!" );
1192+ }
11551193
11561194 joinList .add (j );
11571195
0 commit comments