@@ -128,7 +128,7 @@ public String getUserIdKey() {
128128 //array item >>>>>>>>>>
129129 private boolean test ; //测试
130130 private boolean cacheStatic ; //静态缓存
131-
131+
132132 private String procedure ;
133133 public SQLConfig setProcedure (String procedure ) {
134134 this .procedure = procedure ;
@@ -340,8 +340,8 @@ public String getGroupString(boolean hasPrefix) {
340340
341341 }
342342 }
343-
344-
343+
344+
345345 group = StringUtil .getTrimedString (group );
346346 String [] keys = StringUtil .split (group );
347347 if (keys == null || keys .length <= 0 ) {
@@ -400,7 +400,7 @@ public String getHavingString(boolean hasPrefix) {
400400
401401 }
402402 }
403-
403+
404404 having = StringUtil .getTrimedString (having );
405405 String [] keys = StringUtil .split (having , ";" );
406406 if (keys == null || keys .length <= 0 ) {
@@ -1885,17 +1885,17 @@ public static String getSQL(AbstractSQLConfig config) throws Exception {
18851885 Log .i (TAG , "getSQL config == null >> return null;" );
18861886 return null ;
18871887 }
1888-
1888+
18891889 //TODO procedure 改为 List<Procedure> procedureList; behind : true; function: callFunction(); String key; ...
18901890 // for (...) { Call procedure1();\n SQL \n; Call procedure2(); ... }
18911891 // 貌似不需要,因为 ObjecParser 里就已经处理的顺序等,只是这里要解决下 Schema 问题。
1892-
1892+
18931893 String sch = config .getSQLSchema (config .getSQLTable ());
18941894 if (StringUtil .isNotEmpty (config .getProcedure (), true )) {
18951895 String q = config .getQuote ();
18961896 return "CALL " + q + sch + q + "." + config .getProcedure ();
18971897 }
1898-
1898+
18991899 String tablePath = config .getTablePath ();
19001900 if (StringUtil .isNotEmpty (tablePath , true ) == false ) {
19011901 Log .i (TAG , "getSQL StringUtil.isNotEmpty(tablePath, true) == false >> return null;" );
@@ -2069,20 +2069,29 @@ public String getJoinString() throws Exception {
20692069 * @return
20702070 * @throws Exception
20712071 */
2072- public static AbstractSQLConfig newSQLConfig (RequestMethod method , String table , JSONObject request , List <Join > joinList , Callback callback ) throws Exception {
2072+ public static AbstractSQLConfig newSQLConfig (RequestMethod method , String table , JSONObject request , List <Join > joinList , boolean isProcedure , Callback callback ) throws Exception {
20732073 if (request == null ) { // User:{} 这种空内容在查询时也有效
20742074 throw new NullPointerException (TAG + ": newSQLConfig request == null!" );
20752075 }
20762076 AbstractSQLConfig config = callback .getSQLConfig (method , table );
20772077
20782078 //放后面会导致主表是空对象时 joinList 未解析
2079- config = parseJoin (method , config , joinList , callback );
2079+ if (isProcedure == false ) {
2080+ config = parseJoin (method , config , joinList , callback );
2081+ }
20802082
20812083 if (request .isEmpty ()) { // User:{} 这种空内容在查询时也有效
20822084 return config ; //request.remove(key); 前都可以直接return,之后必须保证 put 回去
20832085 }
20842086
2087+ String database = request .getString (KEY_DATABASE );
20852088 String schema = request .getString (KEY_SCHEMA );
2089+ config .setDatabase (database ); //不删,后面表对象还要用的
2090+ config .setSchema (schema ); //不删,后面表对象还要用的
2091+
2092+ if (isProcedure ) {
2093+ return config ;
2094+ }
20862095
20872096 String idKey = callback .getIdKey (schema , table );
20882097 String idInKey = idKey + "{}" ;
@@ -2128,7 +2137,6 @@ else if (id instanceof Subquery) {}
21282137
21292138
21302139 String role = request .getString (KEY_ROLE );
2131- String database = request .getString (KEY_DATABASE );
21322140 String combine = request .getString (KEY_COMBINE );
21332141 Subquery from = (Subquery ) request .get (KEY_FROM );
21342142 String column = request .getString (KEY_COLUMN );
@@ -2329,8 +2337,6 @@ else if (whereList != null && whereList.contains(key)) {
23292337 //在 tableWhere 第0个 config.setIdIn(idIn);
23302338
23312339 config .setRole (role );
2332- config .setDatabase (database );
2333- config .setSchema (schema );
23342340 config .setGroup (group );
23352341 config .setHaving (having );
23362342 config .setOrder (order );
@@ -2378,8 +2384,8 @@ public static AbstractSQLConfig parseJoin(RequestMethod method, AbstractSQLConfi
23782384 for (Join j : joinList ) {
23792385 name = j .getName ();
23802386 //JOIN子查询不能设置LIMIT,因为ON关系是在子查询后处理的,会导致结果会错误
2381- SQLConfig joinConfig = newSQLConfig (method , name , j .getTable (), null , callback );
2382- SQLConfig cacheConfig = newSQLConfig (method , name , j .getTable (), null , callback ).setCount (1 );
2387+ SQLConfig joinConfig = newSQLConfig (method , name , j .getTable (), null , false , callback );
2388+ SQLConfig cacheConfig = newSQLConfig (method , name , j .getTable (), null , false , callback ).setCount (1 );
23832389
23842390 if (j .isAppJoin () == false ) { //除了 @ APP JOIN,其它都是 SQL JOIN,则副表要这样配置
23852391 if (isQuery ) {
@@ -2389,7 +2395,7 @@ public static AbstractSQLConfig parseJoin(RequestMethod method, AbstractSQLConfi
23892395 joinConfig .setMain (false ).setKeyPrefix (true );
23902396
23912397 if (j .isLeftOrRightJoin ()) {
2392- SQLConfig outterConfig = newSQLConfig (method , name , j .getOutter (), null , callback );
2398+ SQLConfig outterConfig = newSQLConfig (method , name , j .getOutter (), null , false , callback );
23932399 outterConfig .setMain (false ).setKeyPrefix (true );
23942400 j .setOutterConfig (outterConfig );
23952401 }
0 commit comments