@@ -5704,7 +5704,7 @@ https://github.com/Tencent/APIJSON/issues
57045704 if (show) {
57055705 var testCases = this.testCases
57065706 var allCount = testCases == null ? 0 : testCases.length
5707- App .allCount = allCount
5707+ this .allCount = allCount
57085708 if (allCount > 0) {
57095709 if (! (this.isAllSummaryShow() || this.isCurrentSummaryShow())) {
57105710 this.showCompare4TestCaseList(show, this.isChainShow)
@@ -9033,7 +9033,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
90339033 'detail()': 'getFunctionDetail()',
90349034 'name$': search,
90359035 'detail$': search,
9036- '@combine': search == null ? null : 'name$,detail$',
9036+ '@combine': StringUtil.isEmpty( search) ? null : 'name$,detail$',
90379037 }
90389038 },
90399039 'Request[]': {
@@ -10897,7 +10897,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1089710897 const start = value.indexOf('(');
1089810898 const end = value.lastIndexOf(')');
1089910899
10900- var request4Db = function(tableName, which, p_k, pathKeys, key, lastKeyInPath, isRandom, isDesc, step) {
10900+ var request4Db = function(tableName, which, p_k, pathKeys, key, lastKeyInPath, isRandom, isDesc, step, body ) {
1090110901 // const tableName = JSONResponse.getTableName(pathKeys[pathKeys.length - 2]);
1090210902 vOutput.value = 'requesting value for ' + tableName + '/' + key + ' from database...';
1090310903
@@ -10917,19 +10917,32 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1091710917 column = column.substring(1, column.length - 1);
1091810918 }
1091910919
10920- const finalTableName = StringUtil.isEmpty(table, true) ? tableName : table;
10920+ var sch_tbl = StringUtil.isEmpty(table, true) ? tableName : table;
10921+ var ind = sch_tbl.indexOf('.');
10922+ var schema = ind < 0 ? App.schema : sch_tbl.substring(0, ind);
10923+ const finalTableName = StringUtil.firstCase(ind < 0 ? sch_tbl : sch_tbl.substring(ind + 1), true);
1092110924 const finalColumnName = StringUtil.isEmpty(column, true) ? lastKeyInPath : column;
1092210925
10923- const tableReq = {
10926+ var tableReq = {
1092410927 '@column': isRandom ? finalColumnName : ('DISTINCT ' + finalColumnName),
10925- '@order': isRandom ? 'rand()' : (finalColumnName + (isDesc ? '-' : '+'))
10928+ '@order': isRandom ? 'rand()' : (finalColumnName + (isDesc ? '-' : '+')),
10929+ '@schema': StringUtil.isEmpty(schema, true) ? undefined : schema
1092610930 };
1092710931 tableReq[finalColumnName + '>='] = min;
1092810932 tableReq[finalColumnName + '<='] = max;
10933+ try {
10934+ body = parseJSON(body);
10935+ } catch (e) {
10936+ console.log(e);
10937+ }
1092910938
10930- const req = {};
10939+ var req = {};
1093110940 const listName = isRandom ? null : finalTableName + '-' + finalColumnName + '[]';
10932- const orderIndex = isRandom ? null : getOrderIndex(randomId, line, null)
10941+ const orderIndex = isRandom ? null : getOrderIndex(randomId, line, null);
10942+
10943+ if (body != null && body[finalTableName] == null && (isRandom || body[listName] == null)) {
10944+ tableReq = Object.assign(tableReq, body);
10945+ }
1093310946
1093410947 if (isRandom) {
1093510948 req[finalTableName] = tableReq;
@@ -10941,11 +10954,19 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1094110954 page: (step*orderIndex) % 100 //暂时先这样,APIJSON 应该改为 count*page <= 10000 //FIXME 上限 100 怎么破,lastKeyInPath 未必是 id
1094210955 };
1094310956 listReq[finalTableName] = tableReq;
10957+
10958+ if (body != null && body[finalTableName] != null) {
10959+ listReq = Object.assign(listReq, body);
10960+ }
1094410961 req[listName] = listReq;
1094510962 }
1094610963
10964+ if (body != null && body[isRandom ? finalTableName : listName] != null) {
10965+ req = Object.assign(req, body);
10966+ }
10967+
1094710968 // reqCount ++;
10948- App.request(true, REQUEST_TYPE_POST, REQUEST_TYPE_JSON, '/get', req, {}, function (url, res, err) {
10969+ App.adminRequest( '/get', req, {}, function (url, res, err) {
1094910970 // respCount ++;
1095010971 try {
1095110972 App.onResponse(url, res, err)
@@ -10968,7 +10989,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1096810989 //越界,重新获取
1096910990 if (val == null && orderIndex > 0 && ORDER_MAP[randomId] != null && ORDER_MAP[randomId][line] != null) {
1097010991 ORDER_MAP[randomId][line] = null; //重置,避免还是在原来基础上叠加
10971- request4Db(JSONResponse.getTableName(pathKeys[pathKeys.length - 2]), which, p_k, pathKeys, key, lastKeyInPath, false, isDesc, step);
10992+ request4Db(JSONResponse.getTableName(pathKeys[pathKeys.length - 2]), which, p_k, pathKeys, key, lastKeyInPath, false, isDesc, step, body );
1097210993 }
1097310994 else {
1097410995 invoke(val, which, p_k, pathKeys, key, lastKeyInPath);
@@ -11025,13 +11046,13 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1102511046 + '\n+,-,step 前后都不能有空格等其它字符!');
1102611047 }
1102711048
11049+ var args = StringUtil.split(value.substring(start + 1, end), ', ') || []
11050+
1102811051 if (fun == ORDER_DB) {
11029- request4Db(JSONResponse.getTableName(pathKeys[pathKeys.length - 2]), which, p_k, pathKeys, key, lastKeyInPath, false, isDesc, step); //request4Db(key + (isDesc ? '-' : '+'), step);
11052+ request4Db(JSONResponse.getTableName(pathKeys[pathKeys.length - 2]), which, p_k, pathKeys, key, lastKeyInPath, false, isDesc, step, args[4] ); //request4Db(key + (isDesc ? '-' : '+'), step);
1103011053 continue;
1103111054 }
1103211055
11033- var args = StringUtil.split(value.substring(start + 1, end))
11034-
1103511056 toEval = (fun == ORDER_IN ? 'orderIn' : (fun == ORDER_INT ? 'orderInt' : (fun == ORDER_BAD_BOOL ? 'orderBadBool' : (fun == ORDER_BAD_NUM
1103611057 ? 'orderBadNum' : (fun == ORDER_BAD_STR ? 'orderBadStr' : (fun == ORDER_BAD_ARR ? 'orderBadArr' : (fun == ORDER_BAD_OBJ ? 'orderBadObj' : 'orderBad')))))))
1103711058 + '(' + (fun == ORDER_BAD ? 'BADS, ' : '') + isDesc + ', ' + getOrderIndex(
@@ -11106,8 +11127,9 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1110611127 else {
1110711128 fun = funWithOrder; //还原,其它函数不支持 升降序和跨步!
1110811129
11109- if (fun == RANDOM_DB) {
11110- request4Db(JSONResponse.getTableName(pathKeys[pathKeys.length - 2]), which, p_k, pathKeys, key, lastKeyInPath, true); //'random()');
11130+ if (fun == RANDOM_DB) { // FIXME 改用 parseJSON('[' + value.substring(start + 1, end) + ']') 兼容复杂表达式
11131+ var args = StringUtil.split(value.substring(start + 1, end), ', ') || []
11132+ request4Db(JSONResponse.getTableName(pathKeys[pathKeys.length - 2]), which, p_k, pathKeys, key, lastKeyInPath, true, null, null, args[4]); //'random()');
1111111133 continue;
1111211134 }
1111311135
0 commit comments