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:
@@ -91,23 +91,20 @@ public class SQLExprTableSource extends SQLTableSourceImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((expr == null) ? 0 : expr.hashCode());
|
||||
return result;
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SQLExprTableSource that = (SQLExprTableSource) o;
|
||||
|
||||
if (expr != null ? !expr.equals(that.expr) : that.expr != null) return false;
|
||||
return partitions != null ? partitions.equals(that.partitions) : that.partitions == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null) return false;
|
||||
if (getClass() != obj.getClass()) return false;
|
||||
SQLExprTableSource other = (SQLExprTableSource) obj;
|
||||
if (expr == null) {
|
||||
if (other.expr != null) return false;
|
||||
} else if (!expr.equals(other.expr)) return false;
|
||||
return true;
|
||||
public int hashCode() {
|
||||
int result = expr != null ? expr.hashCode() : 0;
|
||||
result = 31 * result + (partitions != null ? partitions.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -117,6 +117,21 @@ public class SQLJoinTableSource extends SQLTableSourceImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SQLJoinTableSource that = (SQLJoinTableSource) o;
|
||||
|
||||
if (natural != that.natural) return false;
|
||||
if (left != null ? !left.equals(that.left) : that.left != null) return false;
|
||||
if (joinType != that.joinType) return false;
|
||||
if (right != null ? !right.equals(that.right) : that.right != null) return false;
|
||||
if (condition != null ? !condition.equals(that.condition) : that.condition != null) return false;
|
||||
return using != null ? using.equals(that.using) : that.using == null;
|
||||
}
|
||||
|
||||
public static enum JoinType {
|
||||
COMMA(","), //
|
||||
JOIN("JOIN"), //
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.ast.statement;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLStatementImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
@@ -22,6 +23,11 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
public class SQLRollbackStatement extends SQLStatementImpl {
|
||||
|
||||
private SQLName to;
|
||||
|
||||
// for mysql
|
||||
private Boolean chain;
|
||||
private Boolean release;
|
||||
private SQLExpr force;
|
||||
|
||||
public SQLRollbackStatement() {
|
||||
|
||||
@@ -35,6 +41,8 @@ public class SQLRollbackStatement extends SQLStatementImpl {
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, to);
|
||||
|
||||
acceptChild(visitor, force);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
@@ -47,4 +55,28 @@ public class SQLRollbackStatement extends SQLStatementImpl {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public Boolean getChain() {
|
||||
return chain;
|
||||
}
|
||||
|
||||
public void setChain(Boolean chain) {
|
||||
this.chain = chain;
|
||||
}
|
||||
|
||||
public Boolean getRelease() {
|
||||
return release;
|
||||
}
|
||||
|
||||
public void setRelease(Boolean release) {
|
||||
this.release = release;
|
||||
}
|
||||
|
||||
public SQLExpr getForce() {
|
||||
return force;
|
||||
}
|
||||
|
||||
public void setForce(SQLExpr force) {
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user