improved sql parser.

This commit is contained in:
wenshao
2017-03-13 23:07:26 +08:00
parent 190faee6d2
commit 781f4de2b4
12 changed files with 250 additions and 6 deletions
@@ -25,7 +25,7 @@ public class MySqlOutFileExpr extends MySqlObjectImpl implements SQLExpr {
private SQLExpr file;
private String charset;
private SQLLiteralExpr columnsTerminatedBy;
private SQLExpr columnsTerminatedBy;
private boolean columnsEnclosedOptionally = false;
private SQLLiteralExpr columnsEnclosedBy;
private SQLLiteralExpr columnsEscaped;
@@ -66,11 +66,11 @@ public class MySqlOutFileExpr extends MySqlObjectImpl implements SQLExpr {
this.charset = charset;
}
public SQLLiteralExpr getColumnsTerminatedBy() {
public SQLExpr getColumnsTerminatedBy() {
return columnsTerminatedBy;
}
public void setColumnsTerminatedBy(SQLLiteralExpr columnsTerminatedBy) {
public void setColumnsTerminatedBy(SQLExpr columnsTerminatedBy) {
this.columnsTerminatedBy = columnsTerminatedBy;
}
@@ -328,7 +328,7 @@ public class MySqlSelectParser extends SQLSelectParser {
lexer.nextToken();
accept(Token.BY);
}
outFile.setColumnsTerminatedBy((SQLLiteralExpr) expr());
outFile.setColumnsTerminatedBy(expr());
if (identifierEquals("OPTIONALLY")) {
lexer.nextToken();
@@ -250,6 +250,9 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
@Override
public boolean visit(MySqlKey x) {
for (SQLObject item : x.getColumns()) {
item.accept(this);
}
return false;
}
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2101 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.sql.dialect.odps.ast;
import com.alibaba.druid.sql.ast.SQLName;
@@ -236,7 +236,6 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
print0(ucase ? "DELETE " : "delete ");
SQLTableSource tableSource = x.getTableSource();
if (x.getHints().size() > 0) {
printAndAccept(x.getHints(), ", ");
print(' ');