Skip to content

Commit 6e73efb

Browse files
authored
Merge pull request #356 from chenyanlann/master
Update AbstractSQLExecutor.java
2 parents d41f2a4 + dae5ac9 commit 6e73efb

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

APIJSONORM/src/main/java/apijson/orm/AbstractSQLExecutor.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -710,11 +710,15 @@ protected String getKey(@NotNull SQLConfig config, @NotNull ResultSet rs, @NotNu
710710
, final int tablePosition, @NotNull JSONObject table, final int columnIndex, Map<String, JSONObject> childMap) throws Exception {
711711
String key = rsmd.getColumnLabel(columnIndex);// dotIndex < 0 ? lable : lable.substring(dotIndex + 1);
712712
if (config.isHive()) {
713-
String table_name = config.getTable();
714-
if(AbstractSQLConfig.TABLE_KEY_MAP.containsKey(table_name)) table_name = AbstractSQLConfig.TABLE_KEY_MAP.get(table_name);
715-
String pattern = "^" + table_name + "\\." + "[a-zA-Z]+$";
713+
String tableName = config.getTable();
714+
if (AbstractSQLConfig.TABLE_KEY_MAP.containsKey(tableName)) {
715+
tableName = AbstractSQLConfig.TABLE_KEY_MAP.get(tableName);
716+
}
717+
String pattern = "^" + tableName + "\\." + "[a-zA-Z]+$";
716718
boolean isMatch = Pattern.matches(pattern, key);
717-
if(isMatch) key = key.split("\\.")[1];
719+
if (isMatch) {
720+
key = key.split("\\.")[1];
721+
}
718722
}
719723
return key;
720724
}
@@ -972,7 +976,9 @@ public ResultSet executeQuery(@NotNull SQLConfig config) throws Exception {
972976
public int executeUpdate(@NotNull SQLConfig config) throws Exception {
973977
PreparedStatement s = getStatement(config);
974978
int count = s.executeUpdate(); //PreparedStatement 不用传 SQL
975-
if (config.isHive() && count==0) count = 1;
979+
if (config.isHive() && count == 0) {
980+
count = 1;
981+
}
976982

977983
if (config.getMethod() == RequestMethod.POST && config.getId() == null) { //自增id
978984
ResultSet rs = s.getGeneratedKeys();

0 commit comments

Comments
 (0)