Skip to content

修改源代码遇到的问题 #3

@chenyanlann

Description

@chenyanlann

关于"`"的问题

(使用JDBC驱动clickhouse4j时)

在ClickHouse中是可以使用"`"的

例如查询

SELECT `Comment`.*, `User`.`id`,`User`.`name` FROM `sys`.`Comment` AS `Comment`  
   INNER JOIN `sys`.`apijson_user` AS `User` ON `User`.`id` = `Comment`.`userId` WHERE  (  (  (match(`Comment`.`content`, 'a'))  )  AND  (  (  (match(`User`.`name`, 'a') OR match(`User`.`name`, 't'))  )  )  )  ORDER BY `Comment`.`date` DESC  LIMIT 10

ClickHouse可以正确返回结果,但是最后的请求结果却是:

 {

    "ok": true ,
    "code": 200 ,
    "msg": "success" ,
    "sql:generate|cache|execute|maxExecute": "1|0|1|200" ,
    "depth:count|max": "3|5" ,
    "time:start|duration|end": "1627816512477|605|1627816513082" 

}

看一下控制台输出的日志记录,发现AbstractParser提前结束了:

2021-08-01 07:15:13.082: AbstractParser.DEBUG: putQueryResult queryResultMap.containsKey(valuePath) >> queryResultMap.put(path, result);
2021-08-01 07:15:13.082:

AbstractParser.DEBUG: <<<<<<<<<<<<<<<<<<<<<<< close >>>>>>>>>>>>>>>>>>>>>>>

排查发现apijson.orm.AbstractSQLExecutor.execute中的代码:

} else if (!config.getSQLTable().equalsIgnoreCase(rsmd.getTableName(i))) {
    viceColumnStart = i;
}

在执行时rsmd.getTableName返回"‘Comment’",而和它比较的字符串却是"Comment"

由于在ClickHouse中可以不使用"`"

在getQuote()中去掉"`"可以返回正确结果

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions