Skip to content
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

sqlline.SqlLine#dequote fails with StringIndexOutOfBoundsException in case of odd number of quotes #87

Closed
snuyanzin opened this issue Jul 31, 2018 · 1 comment

Comments

@snuyanzin
Copy link
Collaborator

while testing #86 faced with the issue
0: jdbc:calcite:model=target/test-classes/mod> !set csvDelimiter '
fails with

java.lang.StringIndexOutOfBoundsException: begin 1, end 0, length 1
        at java.base/java.lang.String.checkBoundsBeginEnd(Unknown Source)
        at java.base/java.lang.String.substring(Unknown Source)
        at sqlline.SqlLine.dequote(SqlLine.java:1323)
        at sqlline.SqlLine.split(SqlLine.java:1336)
        at sqlline.SqlLine.split(SqlLine.java:1155)
        at sqlline.AbstractCommandHandler.matches(AbstractCommandHandler.java:65)
        at sqlline.SqlLine.dispatch(SqlLine.java:775)
        at sqlline.SqlLine.begin(SqlLine.java:669)
        at sqlline.SqlLine.start(SqlLine.java:374)
        at sqlline.SqlLine.main(SqlLine.java:266)

the solution might be to add checking non-one length for while cycle

    while (str.startsWith("'") && str.endsWith("'")
        || str.startsWith("\"") && str.endsWith("\"")) {
      str = str.substring(1, str.length() - 1);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants