mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve test case for sql variant ref expr ;
improve test cast for parameterized
This commit is contained in:
@@ -30,7 +30,7 @@ public class SQLVariantRefExpr extends SQLExprImpl {
|
||||
|
||||
private boolean global = false;
|
||||
|
||||
private boolean hasSessionBefore = false;
|
||||
private boolean session = false;
|
||||
|
||||
private int index = -1;
|
||||
|
||||
@@ -43,10 +43,10 @@ public class SQLVariantRefExpr extends SQLExprImpl {
|
||||
this.global = global;
|
||||
}
|
||||
|
||||
public SQLVariantRefExpr(String name, boolean global,boolean hasSessionBefore){
|
||||
public SQLVariantRefExpr(String name, boolean global,boolean session){
|
||||
this.name = name;
|
||||
this.global = global;
|
||||
this.hasSessionBefore = hasSessionBefore;
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public SQLVariantRefExpr(){
|
||||
@@ -74,12 +74,12 @@ public class SQLVariantRefExpr extends SQLExprImpl {
|
||||
}
|
||||
|
||||
|
||||
public boolean isHasSessionBefore() {
|
||||
return hasSessionBefore;
|
||||
public boolean isSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
public void setHasSessionBefore(boolean hasSessionBefore) {
|
||||
this.hasSessionBefore = hasSessionBefore;
|
||||
public void setSession(boolean session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-5
@@ -29,15 +29,15 @@ public class MySqlSetTransactionStatement extends MySqlStatementImpl {
|
||||
|
||||
private String accessModel;
|
||||
|
||||
private Boolean hasSessionBefore;
|
||||
private Boolean session;
|
||||
|
||||
|
||||
public Boolean getHasSessionBefore() {
|
||||
return hasSessionBefore;
|
||||
public Boolean getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
public void setHasSessionBefore(Boolean hasSessionBefore) {
|
||||
this.hasSessionBefore = hasSessionBefore;
|
||||
public void setSession(Boolean session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
public void accept0(MySqlASTVisitor visitor) {
|
||||
|
||||
@@ -2609,20 +2609,20 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
Boolean global = null;
|
||||
Boolean sessionBefore = null;
|
||||
Boolean session = null;
|
||||
if (lexer.identifierEquals(GLOBAL)) {
|
||||
global = Boolean.TRUE;
|
||||
lexer.nextToken();
|
||||
} else if (lexer.identifierEquals(SESSION)) {
|
||||
global = Boolean.FALSE;
|
||||
sessionBefore = Boolean.TRUE;
|
||||
session = Boolean.TRUE;
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals("TRANSACTION")) {
|
||||
MySqlSetTransactionStatement stmt = new MySqlSetTransactionStatement();
|
||||
stmt.setGlobal(global);
|
||||
stmt.setHasSessionBefore(sessionBefore);
|
||||
stmt.setSession(session);
|
||||
|
||||
lexer.nextToken();
|
||||
if (lexer.identifierEquals("ISOLATION")) {
|
||||
@@ -2722,14 +2722,14 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
parseAssignItems(stmt.getItems(), stmt);
|
||||
|
||||
if (global != null && global.booleanValue()) {
|
||||
if (global != null && global) {
|
||||
SQLVariantRefExpr varRef = (SQLVariantRefExpr) stmt.getItems().get(0).getTarget();
|
||||
varRef.setGlobal(true);
|
||||
}
|
||||
|
||||
if(sessionBefore != null && sessionBefore.booleanValue()){
|
||||
if(session != null && session){
|
||||
SQLVariantRefExpr varRef = (SQLVariantRefExpr) stmt.getItems().get(0).getTarget();
|
||||
varRef.setHasSessionBefore(true);
|
||||
varRef.setSession(true);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.HINT) {
|
||||
|
||||
@@ -655,7 +655,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
|
||||
if (x.isGlobal()) {
|
||||
print0("@@global.");
|
||||
}else if(x.isHasSessionBefore()){
|
||||
}else if(x.isSession()){
|
||||
print0("@@session.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user