@@ -128,6 +128,15 @@ public String getUserIdKey() {
128128 //array item >>>>>>>>>>
129129 private boolean test ; //测试
130130 private boolean cacheStatic ; //静态缓存
131+
132+ private String procedure ;
133+ public SQLConfig setProcedure (String procedure ) {
134+ this .procedure = procedure ;
135+ return this ;
136+ }
137+ public String getProcedure () {
138+ return procedure ;
139+ }
131140
132141 public AbstractSQLConfig (RequestMethod method ) {
133142 setMethod (method );
@@ -218,6 +227,21 @@ public String getQuote() {
218227 public String getSchema () {
219228 return schema ;
220229 }
230+ public String getSQLSchema (String sqlTable ) {
231+ String sch = getSchema ();
232+ if (sch == null ) { //PostgreSQL 的 pg_class 和 pg_attribute 表好像不属于任何 Schema StringUtil.isEmpty(sch, true)) {
233+ if ((Table .TABLE_NAME .equals (sqlTable ) || Column .TABLE_NAME .equals (sqlTable )) ) {
234+ sch = SCHEMA_INFORMATION ;
235+ }
236+ else if ((PgAttribute .TABLE_NAME .equals (sqlTable ) || PgClass .TABLE_NAME .equals (sqlTable )) ) {
237+ sch = "" ;
238+ }
239+ else {
240+ sch = DEFAULT_SCHEMA ;
241+ }
242+ }
243+ return sch ;
244+ }
221245 @ Override
222246 public AbstractSQLConfig setSchema (String schema ) {
223247 if (schema != null ) {
@@ -255,18 +279,7 @@ public String getTablePath() {
255279 String q = getQuote ();
256280
257281 String sqlTable = getSQLTable ();
258- String sch = getSchema ();
259- if (sch == null ) { //PostgreSQL 的 pg_class 和 pg_attribute 表好像不属于任何 Schema StringUtil.isEmpty(sch, true)) {
260- if ((Table .TABLE_NAME .equals (sqlTable ) || Column .TABLE_NAME .equals (sqlTable )) ) {
261- sch = SCHEMA_INFORMATION ;
262- }
263- else if ((PgAttribute .TABLE_NAME .equals (sqlTable ) || PgClass .TABLE_NAME .equals (sqlTable )) ) {
264- sch = "" ;
265- }
266- else {
267- sch = DEFAULT_SCHEMA ;
268- }
269- }
282+ String sch = getSQLSchema (sqlTable );
270283
271284 return (StringUtil .isEmpty (sch , true ) ? "" : q + sch + q + "." ) + q + sqlTable + q + ( isKeyPrefix () ? " AS " + getAlias () : "" );
272285 }
@@ -1868,7 +1881,22 @@ public String getSQL(boolean prepared) throws Exception {
18681881 * @throws Exception
18691882 */
18701883 public static String getSQL (AbstractSQLConfig config ) throws Exception {
1871- String tablePath = config == null ? null : config .getTablePath ();
1884+ if (config == null ) {
1885+ Log .i (TAG , "getSQL config == null >> return null;" );
1886+ return null ;
1887+ }
1888+
1889+ //TODO procedure 改为 List<Procedure> procedureList; behind : true; function: callFunction(); String key; ...
1890+ // for (...) { Call procedure1();\n SQL \n; Call procedure2(); ... }
1891+ // 貌似不需要,因为 ObjecParser 里就已经处理的顺序等,只是这里要解决下 Schema 问题。
1892+
1893+ String sch = config .getSQLSchema (config .getSQLTable ());
1894+ if (StringUtil .isNotEmpty (config .getProcedure (), true )) {
1895+ String q = config .getQuote ();
1896+ return "CALL " + q + sch + q + "." + config .getProcedure ();
1897+ }
1898+
1899+ String tablePath = config .getTablePath ();
18721900 if (StringUtil .isNotEmpty (tablePath , true ) == false ) {
18731901 Log .i (TAG , "getSQL StringUtil.isNotEmpty(tablePath, true) == false >> return null;" );
18741902 return null ;
0 commit comments