You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/22 13:19:25 UTC
[GitHub] [shardingsphere] tristaZero opened a new issue #7894: Support format inputed SQL with SQL parser engine
tristaZero opened a new issue #7894:
URL: https://github.com/apache/shardingsphere/issues/7894
This feature is to format the inputted SQL. Here is a example.
The inputted SQL is
```sql
select id, name, code from users where id=1 and name=(select name from teachers where id=2);
```
The output SQL could be
```sql
select id, name, code
from users
where id=1
and
name = (
select name
from teachers
where id=2);
```
Hey, the case above is just an example, which means the output SQL may be different, but the mechanisms are the same!
The programming entrance of this feature basically finished, please refer to,
```java
String formatResult =
(String) SQLVisitorFactory.newInstance(databaseTypeName, SQLVisitorType.FORMAT, SQLVisitorRule.valueOf(parseTree.getClass())).visit(parseTree);
// As you know the visitor factory looks familiar with the following one in `StandardSQLParserEngine.JAVA`
SQLStatement result =
(SQLStatement) SQLVisitorFactory.newInstance(databaseTypeName, SQLVisitorType.STATEMENT, SQLVisitorRule.valueOf(parseTree.getClass())).visit(parseTree);
```
What's more, `MySQLFormatSQLVisitorFacade` is prepared for your endeavor and enthusiasm!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] jingshanglu commented on issue #7894: Support format inputted SQL with SQL parser engine
Posted by GitBox <gi...@apache.org>.
jingshanglu commented on issue #7894:
URL: https://github.com/apache/shardingsphere/issues/7894#issuecomment-774615468
#8116 has fixed it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] jingshanglu closed issue #7894: Support format inputted SQL with SQL parser engine
Posted by GitBox <gi...@apache.org>.
jingshanglu closed issue #7894:
URL: https://github.com/apache/shardingsphere/issues/7894
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org