You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2022/04/12 01:00:00 UTC

[jira] [Resolved] (CALCITE-5088) Generated model should escape backslashes

     [ https://issues.apache.org/jira/browse/CALCITE-5088?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde resolved CALCITE-5088.
----------------------------------
    Resolution: Fixed

Fixed inĀ [e08ca8c5|https://github.com/apache/calcite/commit/e08ca8c5df5dee154ae1a1e6adfa2f9ce693ccf7].

> 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)