@@ -253,7 +253,7 @@ public String getSQLTable() {
253253 @ Override
254254 public String getTablePath () {
255255 String q = getQuote ();
256-
256+
257257 String sqlTable = getSQLTable ();
258258 String sch = getSchema ();
259259 if (sch == null ) { //PostgreSQL 的 pg_class 和 pg_attribute 表好像不属于任何 Schema StringUtil.isEmpty(sch, true)) {
@@ -267,7 +267,7 @@ else if ((PgAttribute.TABLE_NAME.equals(sqlTable) || PgClass.TABLE_NAME.equals(s
267267 sch = DEFAULT_SCHEMA ;
268268 }
269269 }
270-
270+
271271 return (StringUtil .isEmpty (sch , true ) ? "" : q + sch + q + "." ) + q + sqlTable + q + ( isKeyPrefix () ? " AS " + getAlias () : "" );
272272 }
273273 @ Override
@@ -536,7 +536,7 @@ public String getColumnString(boolean inSQLJoin) throws Exception {
536536 throw new IllegalArgumentException ("POST请求: 每一个 key:value 中的key都必须是1个单词!" );
537537 }
538538 s += ((pfirst ? "" : "," ) + getKey (c ));
539-
539+
540540 pfirst = false ;
541541 }
542542
@@ -546,6 +546,7 @@ public String getColumnString(boolean inSQLJoin) throws Exception {
546546 boolean isQuery = RequestMethod .isQueryMethod (method );
547547 String joinColumn = "" ;
548548 if (isQuery && joinList != null ) {
549+ SQLConfig ecfg ;
549550 SQLConfig cfg ;
550551 String c ;
551552 boolean first = true ;
@@ -554,7 +555,14 @@ public String getColumnString(boolean inSQLJoin) throws Exception {
554555 continue ;
555556 }
556557
557- cfg = j .getJoinConfig ();
558+ ecfg = j .getOutterConfig ();
559+ if (ecfg != null && ecfg .getColumn () != null ) { //优先级更高
560+ cfg = ecfg ;
561+ }
562+ else {
563+ cfg = j .getJoinConfig ();
564+ }
565+
558566 cfg .setAlias (cfg .getTable ());
559567
560568 c = ((AbstractSQLConfig ) cfg ).getColumnString (true );
@@ -945,12 +953,12 @@ else if (andList == null || andList.contains(key) == false) {
945953 andList = new ArrayList <>();
946954 }
947955 else if (prior && andList .isEmpty () == false ) {
948-
956+
949957 String idKey = getIdKey ();
950958 String idInKey = idKey + "{}" ;
951959 String userIdKey = getUserIdKey ();
952960 String userIdInKey = userIdKey + "{}" ;
953-
961+
954962 if (andList .contains (idKey )) {
955963 i ++;
956964 }
@@ -1625,7 +1633,7 @@ public String getContainString(String key, Object[] childs, int type) throws Ill
16251633 if (childs [i ] instanceof JSON ) {
16261634 throw new IllegalArgumentException (key + "<>:value 中value类型不能为JSON!" );
16271635 }
1628-
1636+
16291637 if (DATABASE_POSTGRESQL .equals (getDatabase ())) {
16301638 condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR ))
16311639 + getKey (key ) + " @> " + getValue (newJSONArray (childs [i ])); //operator does not exist: jsonb @> character varying "[" + childs[i] + "]");
@@ -1938,7 +1946,7 @@ public String getJoinString() throws Exception {
19381946 + quote + tn + quote + "." + quote + j .getTargetKey () + quote ;
19391947 jc .setMain (false ).setKeyPrefix (true );
19401948
1941- // preparedValueList.addAll(jc.getPreparedValueList());
1949+ // preparedValueList.addAll(jc.getPreparedValueList());
19421950
19431951 pvl .addAll (jc .getPreparedValueList ());
19441952 changed = true ;
@@ -1989,9 +1997,9 @@ public static AbstractSQLConfig newSQLConfig(RequestMethod method, String table,
19891997 if (request .isEmpty ()) { // User:{} 这种空内容在查询时也有效
19901998 return config ; //request.remove(key); 前都可以直接return,之后必须保证 put 回去
19911999 }
1992-
2000+
19932001 String schema = request .getString (KEY_SCHEMA );
1994-
2002+
19952003 String idKey = callback .getIdKey (schema , table );
19962004 String idInKey = idKey + "{}" ;
19972005 String userIdKey = callback .getUserIdKey (schema , table );
@@ -2295,6 +2303,12 @@ public static AbstractSQLConfig parseJoin(RequestMethod method, AbstractSQLConfi
22952303 }
22962304
22972305 joinConfig .setMain (false ).setKeyPrefix (true );
2306+
2307+ if ("<" .equals (j .getJoinType ()) || ">" .equals (j .getJoinType ())) {
2308+ SQLConfig outterConfig = newSQLConfig (method , name , j .getOutter (), null , callback );
2309+ outterConfig .setMain (false ).setKeyPrefix (true );
2310+ j .setOutterConfig (outterConfig );
2311+ }
22982312 }
22992313
23002314 //解决 query: 1/2 查数量时报错
@@ -2444,22 +2458,22 @@ public static interface Callback {
24442458 * @return
24452459 */
24462460 Object newId (RequestMethod method , String table );
2447-
2461+
24482462 /**获取主键名
24492463 * @param schema
24502464 * @param table
24512465 * @return
24522466 */
24532467 String getIdKey (String schema , String table );
2454-
2468+
24552469 /**获取 User 的主键名
24562470 * @param schema
24572471 * @param table
24582472 * @return
24592473 */
24602474 String getUserIdKey (String schema , String table );
24612475 }
2462-
2476+
24632477 public static abstract class SimpleCallback implements Callback {
24642478
24652479
@@ -2477,7 +2491,7 @@ public String getIdKey(String schema, String table) {
24772491 public String getUserIdKey (String schema , String table ) {
24782492 return KEY_USER_ID ;
24792493 }
2480-
2494+
24812495 }
24822496
24832497}
0 commit comments