mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sql parser, support sql server
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.ast.statement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLObjectImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
@@ -22,22 +25,22 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
public class SQLAlterTableDropColumnItem extends SQLObjectImpl implements SQLAlterTableItem {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private SQLName columnName;
|
||||
private List<SQLName> columns = new ArrayList<SQLName>();
|
||||
|
||||
public SQLAlterTableDropColumnItem(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, columnName);
|
||||
acceptChild(visitor, columns);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public SQLName getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void setColumnName(SQLName columnName) {
|
||||
this.columnName = columnName;
|
||||
public List<SQLName> getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
@SuppressWarnings("serial")
|
||||
public class SQLColumnDefinition extends SQLObjectImpl implements SQLTableElement {
|
||||
|
||||
private SQLName name;
|
||||
private SQLDataType dataType;
|
||||
private SQLExpr defaultExpr;
|
||||
private final List<SQLColumnConstraint> constaints = new ArrayList<SQLColumnConstraint>(0);
|
||||
private String comment;
|
||||
protected SQLName name;
|
||||
protected SQLDataType dataType;
|
||||
protected SQLExpr defaultExpr;
|
||||
protected final List<SQLColumnConstraint> constaints = new ArrayList<SQLColumnConstraint>(0);
|
||||
protected String comment;
|
||||
|
||||
private Boolean enable;
|
||||
protected Boolean enable;
|
||||
|
||||
public SQLColumnDefinition(){
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLCreateIndexStatement extends SQLStatementImpl implements SQLDDLStatement {
|
||||
|
||||
@@ -36,10 +37,14 @@ public class SQLCreateIndexStatement extends SQLStatementImpl implements SQLDDLS
|
||||
|
||||
private String type;
|
||||
|
||||
public SQLCreateIndexStatement(){
|
||||
|
||||
}
|
||||
|
||||
public SQLTableSource getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
public void setTable(SQLName table) {
|
||||
this.setTable(new SQLExprTableSource(table));
|
||||
}
|
||||
@@ -72,4 +77,13 @@ public class SQLCreateIndexStatement extends SQLStatementImpl implements SQLDDLS
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, getName());
|
||||
acceptChild(visitor, getTable());
|
||||
acceptChild(visitor, getItems());
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 1999-2011 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.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class SQLPrimaryKeyImpl extends SQLUnique implements SQLPrimaryKey {
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, this.getName());
|
||||
acceptChild(visitor, this.getColumns());
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,10 @@ public class SQLUnique extends SQLConstaintImpl implements SQLUniqueConstraint,
|
||||
|
||||
private final List<SQLExpr> columns = new ArrayList<SQLExpr>();
|
||||
|
||||
public SQLUnique(){
|
||||
|
||||
}
|
||||
|
||||
public List<SQLExpr> getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user