[
https://issues.apache.org/jira/browse/CALCITE-5088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17519932#comment-17519932
]
Julian Hyde edited comment on CALCITE-5088 at 4/12/22 1:00 AM:
---------------------------------------------------------------
[~julianhyde] I used your branch(5088-jsonBuilder-escape) to test the case in
CALCITE-4893.
The issue also will be solved by your commit.
was (Author: jiajunbernoulli):
[~julianhyde] I used your branch(5088-jsonBuilder-escape) to test the case in
https://issues.apache.org/jira/browse/CALCITE-4893
The issue also will be solved by your commit.
> Generated model should escape backslashes
> -----------------------------------------
>
> Key: CALCITE-5088
> URL: https://issues.apache.org/jira/browse/CALCITE-5088
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.28.0
> Reporter: Gregory Hart
> Assignee: Julian Hyde
> Priority: Major
> Fix For: 1.31.0
>
>
> When a model is generated (because one is not provided in the JDBC URL), the
> generated JSON does not properly escape backslashes.
> Example in pseudo-code:
> {code:java}
> Properties info = new Properties();
> info.setProperty("schema.jdbcUrl", "jdbc:mssql://host\\THEDB:1443");
> DriverManager.getConnection("jdbc:calcite:", info);
> {code}
> Expected result:
> The connection is opened successfully.
> Actual result:
> com.fasterxml.jackson.core.JsonParseException: Unrecognized character escape
> 'T' (code 84)
> at [Source: (String)"{
> ...
> "jdbcUrl": "jdbc:mssql://host\THEDB:1443"
> ...
> at org.apache.calcite.model.ModelHandler.<init>(ModelHandler.java:101)
> at org.apache.calcite.jdbc.Driver$1.onConnectionInit(Driver.java:101)
> Possible fix:
> Add the following to
> org.apache.calcite.util.JsonBuilder.append(JsonBuilder.java:95). This will
> fix backslashes but there may be other characters that need to be escaped too.
> {code:java}
> .replace("\\", "\\\\")
> {code}
> [https://github.com/apache/calcite/blob/calcite-1.28.0/core/src/main/java/org/apache/calcite/util/JsonBuilder.java#L95]
> It looks like it's being called by
> org.apache.calcite.jdbc.Driver$1.model(Driver.java:153).
--
This message was sent by Atlassian Jira
(v8.20.1#820001)