New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
跨库查询列表语法 #423
Comments
1.你没认真看完常见问题 issue,里面提到调接口热重载方式 2.不是下划线问题,是首字母没大写问题,这点不管是首页 README 注意事项、通用文档、常见问题 issue 全都有说明 |
我提到 3 处,你找到了第 4 处。 首页注意事项不够显眼吗? 常见问题上方 通用文档 另外配套的接口工具 APIAuto 也有静态检查,是没用它还是没看旁边注释? apijson-doc原本是其他热心的开发者贡献的,最近不怎么维护了,APIJSON 官方组织 fork 了一份维护 你要是觉得还不够可以提个 PR 优化文档,或者改源码。 |
1.并没有重启,只是重新加载了配置数据,你可以看 APIJSONController.reload 实现代码 2.MySQL 默认大小写不敏感,SELECT * FROM `Moment` 也可以访问到 `moment` 表。 |
可以给一个重写 getSqLTable 的例子吗? public DemoSQLConfig() {
super();
}
@Override
public String getSQLTable() {
String table = super.getSQLTable();
return table.toLowerCase();
} 这样改写之后,必须要将 Access 改成 access 才能正常启动。
/**判断是否为首字母大写的代码名称
* @param s
* @return
*/
public static boolean isBigName(String s) {
if (s == null || s.isEmpty() || PATTERN_ALPHA_BIG.matcher(s.substring(0, 1)).matches() == false) {
return false;
}
return s.length() <= 1 ? true : PATTERN_NAME.matcher(s.substring(1)).matches();
}
..................................
public static boolean isTableKey(String key) {
return StringUtil.isBigName(key);
}
.........................
//APIJSON Object
boolean isTableKey = JSONRequest.isTableKey(Pair.parseEntry(key, true).getKey());
if (type == TYPE_ITEM && isTableKey == false) {
throw new IllegalArgumentException(parentPath + "/" + key + ":{} 不合法!"
+ "数组 []:{} 中每个 key:{} 都必须是表 TableKey:{} 或 数组 arrayKey[]:{} !");
} 代码里面 ============================ 改造了一下,能够查询出来了:
public DemoSQLConfig() {
super();
}
@Override
public String getSQLTable() {
String table = super.getSQLTable();
String[] str = {"Acess", "Document", "Request", "Response"};
if (Arrays.asList(str).contains(table)) {
return table;
} else {
return table.toLowerCase();
}
}
{
"[]": {
"User_list": {
"@column": "id,user_name",
"@schema": "dict",
},
"count": 3,
},
}
|
Access 表里可以配置 name 和 alias,单个指定请求传参表名和数据库真是表名的映射关系 |
用的postgresql,写在代码中的默认 schema 是 apijson , 此时要查询另外一个 schema dict 中的 user_list 表数据,应该怎么查呢?
这样写会报错:
数组 []:{} 中每个 key:{} 都必须是表 TableKey:{} 或 数组 arrayKey[]:{}
===============
经测试,发现有这样的现象:
满足上面两个条件之后,则可以正常查询。
对于1,用了数据库表还必须重启程序才能生效的做法十分不理解。
对于2,没看到faq里有提到,表名不能包含下划线。
The text was updated successfully, but these errors were encountered: