mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor sql parser
This commit is contained in:
@@ -24,6 +24,9 @@ import java.util.List;
|
||||
public class SQLOrderBy extends SQLObjectImpl {
|
||||
|
||||
protected final List<SQLSelectOrderByItem> items = new ArrayList<SQLSelectOrderByItem>();
|
||||
|
||||
// for postgres
|
||||
private boolean sibings;
|
||||
|
||||
public SQLOrderBy(){
|
||||
|
||||
@@ -44,6 +47,14 @@ public class SQLOrderBy extends SQLObjectImpl {
|
||||
public List<SQLSelectOrderByItem> getItems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public boolean isSibings() {
|
||||
return this.sibings;
|
||||
}
|
||||
|
||||
public void setSibings(boolean sibings) {
|
||||
this.sibings = sibings;
|
||||
}
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
@@ -57,7 +68,8 @@ public class SQLOrderBy extends SQLObjectImpl {
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + items.hashCode();
|
||||
result = prime * result + ((items == null) ? 0 : items.hashCode());
|
||||
result = prime * result + (sibings ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -67,7 +79,11 @@ public class SQLOrderBy extends SQLObjectImpl {
|
||||
if (obj == null) return false;
|
||||
if (getClass() != obj.getClass()) return false;
|
||||
SQLOrderBy other = (SQLOrderBy) obj;
|
||||
return items.equals(other.items);
|
||||
if (items == null) {
|
||||
if (other.items != null) return false;
|
||||
} else if (!items.equals(other.items)) return false;
|
||||
if (sibings != other.sibings) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addItem(SQLExpr expr, SQLOrderingSpecification type) {
|
||||
|
||||
@@ -18,12 +18,20 @@ 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;
|
||||
|
||||
public class SQLAlterTableAddColumn extends SQLObjectImpl implements SQLAlterTableItem {
|
||||
|
||||
private final List<SQLColumnDefinition> columns = new ArrayList<SQLColumnDefinition>();
|
||||
|
||||
|
||||
// for mysql
|
||||
private SQLName firstColumn;
|
||||
private SQLName afterColumn;
|
||||
|
||||
private boolean first;
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
@@ -37,4 +45,27 @@ public class SQLAlterTableAddColumn extends SQLObjectImpl implements SQLAlterTab
|
||||
return columns;
|
||||
}
|
||||
|
||||
public SQLName getFirstColumn() {
|
||||
return firstColumn;
|
||||
}
|
||||
|
||||
public void setFirstColumn(SQLName first) {
|
||||
this.firstColumn = first;
|
||||
}
|
||||
|
||||
public boolean isFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public void setFirst(boolean first) {
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
public SQLName getAfterColumn() {
|
||||
return afterColumn;
|
||||
}
|
||||
|
||||
public void setAfterColumn(SQLName after) {
|
||||
this.afterColumn = after;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ public class SQLCreateIndexStatement extends SQLStatementImpl implements SQLDDLS
|
||||
private List<SQLSelectOrderByItem> items = new ArrayList<SQLSelectOrderByItem>();
|
||||
|
||||
private String type;
|
||||
|
||||
// for mysql
|
||||
private String using;
|
||||
|
||||
public SQLCreateIndexStatement(){
|
||||
|
||||
@@ -75,6 +78,14 @@ public class SQLCreateIndexStatement extends SQLStatementImpl implements SQLDDLS
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUsing() {
|
||||
return using;
|
||||
}
|
||||
|
||||
public void setUsing(String using) {
|
||||
this.using = using;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
|
||||
@@ -24,6 +24,10 @@ public class SQLShowTablesStatement extends SQLStatementImpl {
|
||||
|
||||
protected SQLName database;
|
||||
protected SQLExpr like;
|
||||
|
||||
// for mysql
|
||||
protected boolean full;
|
||||
protected SQLExpr where;
|
||||
|
||||
public SQLName getDatabase() {
|
||||
return database;
|
||||
@@ -49,6 +53,22 @@ public class SQLShowTablesStatement extends SQLStatementImpl {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
return full;
|
||||
}
|
||||
|
||||
public void setFull(boolean full) {
|
||||
this.full = full;
|
||||
}
|
||||
|
||||
public SQLExpr getWhere() {
|
||||
return where;
|
||||
}
|
||||
|
||||
public void setWhere(SQLExpr where) {
|
||||
this.where = where;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
|
||||
Reference in New Issue
Block a user