mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
merge
This commit is contained in:
@@ -1177,7 +1177,7 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
|
||||
String[] filterArray = filters.split("\\,");
|
||||
|
||||
for (String item : filterArray) {
|
||||
FilterManager.loadFilter(this.filters, item);
|
||||
FilterManager.loadFilter(this.filters, item.trim());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +149,8 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
|
||||
public static ThreadLocal<Long> waitNanosLocal = new ThreadLocal<Long>();
|
||||
|
||||
private boolean logDiffrentThread = true;
|
||||
|
||||
public DruidDataSource(){
|
||||
this(false);
|
||||
}
|
||||
@@ -1128,7 +1130,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
return;
|
||||
}
|
||||
|
||||
if (pooledConnection.getOwnerThread() != Thread.currentThread()) {
|
||||
if (logDiffrentThread && pooledConnection.getOwnerThread() != Thread.currentThread()) {
|
||||
LOG.warn("get/close not same thread");
|
||||
}
|
||||
|
||||
@@ -1569,6 +1571,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
value.setTestWhileIdle(this.isTestWhileIdle());
|
||||
|
||||
value.setDefaultAutoCommit(this.isDefaultAutoCommit());
|
||||
|
||||
if (defaultReadOnly != null) {
|
||||
value.setDefaultReadOnly(defaultReadOnly);
|
||||
}
|
||||
@@ -2395,4 +2398,12 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
|
||||
return super.unwrap(iface);
|
||||
}
|
||||
|
||||
public boolean isLogDiffrentThread() {
|
||||
return logDiffrentThread;
|
||||
}
|
||||
|
||||
public void setLogDiffrentThread(boolean logDiffrentThread) {
|
||||
this.logDiffrentThread = logDiffrentThread;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.expr;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLExprImpl;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLBooleanExpr extends SQLExprImpl implements SQLExpr, SQLLiteralExpr {
|
||||
|
||||
private boolean value;
|
||||
|
||||
public SQLBooleanExpr(){
|
||||
|
||||
}
|
||||
|
||||
public SQLBooleanExpr(boolean value){
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(boolean value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
|
||||
visitor.endVisit(this);
|
||||
}
|
||||
|
||||
public void output(StringBuffer buf) {
|
||||
buf.append("x");
|
||||
buf.append(value ? "TRUE" : "FALSE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (value ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SQLBooleanExpr other = (SQLBooleanExpr) obj;
|
||||
if (value != other.value) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -228,7 +228,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
String chars = lexer.stringVal();
|
||||
concat.addParameter(new SQLCharExpr(chars));
|
||||
lexer.nextToken();
|
||||
} while (lexer.token() == Token.LITERAL_CHARS);
|
||||
} while (lexer.token() == Token.LITERAL_CHARS || lexer.token() == Token.LITERAL_ALIAS);
|
||||
expr = concat;
|
||||
}
|
||||
} else if (lexer.token() == Token.IDENTIFIER) {
|
||||
|
||||
@@ -105,6 +105,7 @@ public class MySqlLexer extends Lexer {
|
||||
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
|
||||
if (commentHandler != null && commentHandler.handle(lastToken, stringVal)) {
|
||||
return;
|
||||
@@ -440,6 +441,7 @@ public class MySqlLexer extends Lexer {
|
||||
} else {
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
hasComment = true;
|
||||
}
|
||||
|
||||
if (commentHandler != null && commentHandler.handle(lastToken, stringVal)) {
|
||||
@@ -481,6 +483,7 @@ public class MySqlLexer extends Lexer {
|
||||
|
||||
stringVal = subString(mark, bufPos + 1);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
|
||||
if (commentHandler != null && commentHandler.handle(lastToken, stringVal)) {
|
||||
return;
|
||||
|
||||
@@ -161,7 +161,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
return visit((MySqlSelectQueryBlock) select);
|
||||
}
|
||||
|
||||
return false;
|
||||
return super.visit(select);
|
||||
}
|
||||
|
||||
public boolean visit(MySqlSelectQueryBlock x) {
|
||||
@@ -374,7 +374,6 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
print(" CHARACTER SET ");
|
||||
print(x.getCharSetName());
|
||||
}
|
||||
|
||||
if (x.getCollate() != null) {
|
||||
print(" COLLATE ");
|
||||
print(x.getCollate());
|
||||
|
||||
+18
@@ -22,6 +22,7 @@ import java.util.Properties;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLHexExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLInListExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
|
||||
@@ -31,6 +32,7 @@ import com.alibaba.druid.sql.ast.expr.SQLNumberExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement;
|
||||
import com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils;
|
||||
import com.alibaba.druid.sql.visitor.ParameterizedVisitor;
|
||||
@@ -179,6 +181,22 @@ public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor implemen
|
||||
|
||||
return ParameterizedOutputVisitorUtils.visit(this, x);
|
||||
}
|
||||
|
||||
public boolean visit(SQLHexExpr x) {
|
||||
if (!ParameterizedOutputVisitorUtils.checkParameterize(x)) {
|
||||
return super.visit(x);
|
||||
}
|
||||
|
||||
return ParameterizedOutputVisitorUtils.visit(this, x);
|
||||
}
|
||||
|
||||
public boolean visit(MySqlCharExpr x) {
|
||||
if (!ParameterizedOutputVisitorUtils.checkParameterize(x)) {
|
||||
return super.visit(x);
|
||||
}
|
||||
|
||||
return ParameterizedOutputVisitorUtils.visit(this, x);
|
||||
}
|
||||
|
||||
protected void printValuesList(MySqlInsertStatement x) {
|
||||
List<ValuesClause> valuesList = x.getValuesList();
|
||||
|
||||
@@ -92,6 +92,7 @@ public class OdpsLexer extends Lexer {
|
||||
} else {
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
hasComment = true;
|
||||
}
|
||||
|
||||
if (token != Token.HINT && !isAllowComment()) {
|
||||
@@ -134,6 +135,7 @@ public class OdpsLexer extends Lexer {
|
||||
|
||||
stringVal = subString(mark + 1, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,6 +230,7 @@ public class OracleLexer extends Lexer {
|
||||
} else {
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
hasComment = true;
|
||||
}
|
||||
|
||||
if (token != Token.HINT && !isAllowComment()) {
|
||||
@@ -272,6 +273,7 @@ public class OracleLexer extends Lexer {
|
||||
|
||||
stringVal = subString(mark + 1, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2181,6 +2181,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
}
|
||||
print(";");
|
||||
|
||||
decrementIndent();
|
||||
return false;
|
||||
@@ -2202,6 +2203,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
}
|
||||
print(";");
|
||||
|
||||
decrementIndent();
|
||||
return false;
|
||||
@@ -2232,6 +2234,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
println();
|
||||
}
|
||||
}
|
||||
print(";");
|
||||
decrementIndent();
|
||||
|
||||
for (ElseIf elseIf : x.getElseIfList()) {
|
||||
|
||||
@@ -100,6 +100,7 @@ public class SQLServerLexer extends Lexer {
|
||||
} else {
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
hasComment = true;
|
||||
}
|
||||
|
||||
if (token != Token.HINT && !isAllowComment()) {
|
||||
@@ -142,6 +143,7 @@ public class SQLServerLexer extends Lexer {
|
||||
|
||||
stringVal = subString(mark + 1, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -22,6 +22,7 @@ import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLNCharExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLNullExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLNumberExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr;
|
||||
import com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils;
|
||||
import com.alibaba.druid.sql.visitor.ParameterizedVisitor;
|
||||
|
||||
@@ -90,5 +91,13 @@ public class SQLServerParameterizedOutputVisitor extends SQLServerOutputVisitor
|
||||
|
||||
return ParameterizedOutputVisitorUtils.visit(this, x);
|
||||
}
|
||||
|
||||
public boolean visit(SQLVariantRefExpr x) {
|
||||
if (!ParameterizedOutputVisitorUtils.checkParameterize(x) || x.getName().equalsIgnoreCase("?")) {
|
||||
return super.visit(x);
|
||||
}
|
||||
|
||||
return ParameterizedOutputVisitorUtils.visit(this, x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ public class Lexer {
|
||||
private int varIndex = -1;
|
||||
|
||||
protected CommentHandler commentHandler;
|
||||
|
||||
protected boolean hasComment = false;
|
||||
|
||||
public Lexer(String input){
|
||||
this(input, true);
|
||||
@@ -747,6 +749,7 @@ public class Lexer {
|
||||
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
hasComment = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -777,6 +780,7 @@ public class Lexer {
|
||||
|
||||
stringVal = subString(mark + 1, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1045,4 +1049,8 @@ public class Lexer {
|
||||
|
||||
boolean handle(Token lastToken, String comment);
|
||||
}
|
||||
|
||||
public boolean isHasComment() {
|
||||
return hasComment;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1369,29 +1369,19 @@ public class SQLExprParser extends SQLParser {
|
||||
}
|
||||
charType.setCharSetName(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
if (lexer.stringVal().equalsIgnoreCase("COLLATE")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
}
|
||||
charType.setCollate(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
}
|
||||
}else if(identifierEquals("COLLATE")){
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
}
|
||||
|
||||
charType.setCollate(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
if (lexer.stringVal().equalsIgnoreCase("COLLATE")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
}
|
||||
charType.setCollate(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
}
|
||||
return charType;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLBinaryOperator;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLHexExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLInListExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
|
||||
@@ -55,13 +56,18 @@ public class ParameterizedOutputVisitorUtils {
|
||||
return sql;
|
||||
}
|
||||
|
||||
SQLStatement stmt = statementList.get(0);
|
||||
|
||||
StringBuilder out = new StringBuilder();
|
||||
ParameterizedVisitor visitor = createParameterizedOutputVisitor(out, dbType);
|
||||
stmt.accept(visitor);
|
||||
|
||||
if (visitor.getReplaceCount() == 0) {
|
||||
for (int i = 0; i < statementList.size(); i++) {
|
||||
if (i > 0) {
|
||||
out.append(";\n");
|
||||
}
|
||||
SQLStatement stmt = statementList.get(i);
|
||||
stmt.accept(visitor);
|
||||
}
|
||||
|
||||
if (visitor.getReplaceCount() == 0 && !parser.getLexer().isHasComment()) {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -190,6 +196,18 @@ public class ParameterizedOutputVisitorUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean visit(ParameterizedVisitor v, SQLVariantRefExpr x) {
|
||||
v.print('?');
|
||||
v.incrementReplaceCunt();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean visit(ParameterizedVisitor v, SQLHexExpr x) {
|
||||
v.print('?');
|
||||
v.incrementReplaceCunt();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static SQLBinaryOpExpr merge(ParameterizedVisitor v, SQLBinaryOpExpr x) {
|
||||
SQLExpr left = x.getLeft();
|
||||
SQLExpr right = x.getRight();
|
||||
@@ -198,8 +216,17 @@ public class ParameterizedOutputVisitorUtils {
|
||||
if (left instanceof SQLLiteralExpr && right instanceof SQLLiteralExpr) {
|
||||
if (x.getOperator() == SQLBinaryOperator.Equality //
|
||||
|| x.getOperator() == SQLBinaryOperator.NotEqual) {
|
||||
left.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
right.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
if((left instanceof SQLIntegerExpr) && (right instanceof SQLIntegerExpr) ) {
|
||||
if (((SQLIntegerExpr) left).getNumber().intValue() < 100) {
|
||||
left.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
}
|
||||
if (((SQLIntegerExpr) right).getNumber().intValue() < 100) {
|
||||
right.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
}
|
||||
} else {
|
||||
left.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
right.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTriggerStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTriggerStatement.TriggerEvent;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTriggerStatement.TriggerType;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateViewStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDropDatabaseStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDropFunctionStatement;
|
||||
@@ -608,7 +609,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
decrementIndent();
|
||||
} else if (parent instanceof ValuesClause) {
|
||||
println();
|
||||
print("(");
|
||||
x.getSubQuery().accept(this);
|
||||
print(")");
|
||||
println();
|
||||
} else {
|
||||
print("(");
|
||||
@@ -1418,6 +1421,27 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
x.getName().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLCreateViewStatement x) {
|
||||
print("CREATE ");
|
||||
if(x.isOrReplace()) {
|
||||
print("OR REPLACE ");
|
||||
}
|
||||
print("VIEW ");
|
||||
x.getName().accept(this);
|
||||
|
||||
if (x.getColumns().size() > 0) {
|
||||
print(" (");
|
||||
printAndAccept(x.getColumns(), ", ");
|
||||
print(")");
|
||||
}
|
||||
|
||||
print(" AS ");
|
||||
|
||||
x.getSubQuery().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLAlterTableDropIndex x) {
|
||||
|
||||
@@ -1282,6 +1282,49 @@ public class SQLEvalVisitorUtils {
|
||||
|
||||
return BigInteger.valueOf(((Number) val).longValue());
|
||||
}
|
||||
|
||||
public static Number castToNumber(String val) {
|
||||
if (val == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return Byte.parseByte(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return Short.parseShort(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.parseInt(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return Long.parseLong(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return Float.parseFloat(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return Double.parseDouble(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return new BigInteger(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
return new BigDecimal(val);
|
||||
}
|
||||
|
||||
public static Date castToDate(Object val) {
|
||||
if (val == null) {
|
||||
@@ -1387,6 +1430,14 @@ public class SQLEvalVisitorUtils {
|
||||
if (a == null || b == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (a instanceof String) {
|
||||
a = castToNumber((String) a);
|
||||
}
|
||||
|
||||
if (b instanceof String) {
|
||||
b = castToNumber((String) b);
|
||||
}
|
||||
|
||||
if (a instanceof BigDecimal || b instanceof BigDecimal) {
|
||||
BigDecimal decimalA = castToDecimal(a);
|
||||
@@ -1664,6 +1715,14 @@ public class SQLEvalVisitorUtils {
|
||||
if (a == EVAL_VALUE_NULL || b == EVAL_VALUE_NULL) {
|
||||
return EVAL_VALUE_NULL;
|
||||
}
|
||||
|
||||
if (a instanceof String && !(b instanceof String)) {
|
||||
a = castToNumber((String) a);
|
||||
}
|
||||
|
||||
if (b instanceof String && !(a instanceof String)) {
|
||||
b = castToNumber((String) b);
|
||||
}
|
||||
|
||||
if (a instanceof BigDecimal || b instanceof BigDecimal) {
|
||||
return castToDecimal(a).add(castToDecimal(b));
|
||||
@@ -1704,7 +1763,7 @@ public class SQLEvalVisitorUtils {
|
||||
return castToByte(a) + castToByte(b);
|
||||
}
|
||||
|
||||
if (a instanceof String || b instanceof String) {
|
||||
if (a instanceof String && b instanceof String) {
|
||||
return castToString(a) + castToString(b);
|
||||
}
|
||||
|
||||
@@ -1727,6 +1786,14 @@ public class SQLEvalVisitorUtils {
|
||||
if (a instanceof Date || b instanceof Date) {
|
||||
return SQLEvalVisitor.EVAL_ERROR;
|
||||
}
|
||||
|
||||
if (a instanceof String) {
|
||||
a = castToNumber((String) a);
|
||||
}
|
||||
|
||||
if (b instanceof String) {
|
||||
b = castToNumber((String) b);
|
||||
}
|
||||
|
||||
if (a instanceof BigDecimal || b instanceof BigDecimal) {
|
||||
return castToDecimal(a).subtract(castToDecimal(b));
|
||||
@@ -1767,10 +1834,6 @@ public class SQLEvalVisitorUtils {
|
||||
return castToByte(a) - castToByte(b);
|
||||
}
|
||||
|
||||
if (a instanceof String && b instanceof String) {
|
||||
return castToLong(a) - castToLong(b);
|
||||
}
|
||||
|
||||
// return SQLEvalVisitor.EVAL_ERROR;
|
||||
throw new IllegalArgumentException(a.getClass() + " and " + b.getClass() + " not supported.");
|
||||
}
|
||||
@@ -1780,6 +1843,14 @@ public class SQLEvalVisitorUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (a instanceof String) {
|
||||
a = castToNumber((String) a);
|
||||
}
|
||||
|
||||
if (b instanceof String) {
|
||||
b = castToNumber((String) b);
|
||||
}
|
||||
|
||||
if (a instanceof BigDecimal || b instanceof BigDecimal) {
|
||||
return castToDecimal(a).multiply(castToDecimal(b));
|
||||
}
|
||||
@@ -1787,6 +1858,14 @@ public class SQLEvalVisitorUtils {
|
||||
if (a instanceof BigInteger || b instanceof BigInteger) {
|
||||
return castToBigInteger(a).multiply(castToBigInteger(b));
|
||||
}
|
||||
|
||||
if (a instanceof Double || b instanceof Double) {
|
||||
return castToDouble(a) * castToDouble(b);
|
||||
}
|
||||
|
||||
if (a instanceof Float || b instanceof Float) {
|
||||
return castToFloat(a) * castToFloat(b);
|
||||
}
|
||||
|
||||
if (a instanceof Long || b instanceof Long) {
|
||||
return castToLong(a) * castToLong(b);
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class DruidTest extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DruidDataSource ds = new DruidDataSource();
|
||||
ds.setMaxWait(30);
|
||||
ds.setInitialSize(0);
|
||||
ds.setUrl("jdbc:mysql:xxx");
|
||||
|
||||
try {
|
||||
ds.getConnection();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,13 @@ public class SQLEvalVisitorUtilsTest extends TestCase {
|
||||
Assert.assertEquals(-1, SQLEvalVisitorUtils.evalExpr(JdbcUtils.MYSQL, "? - ?", Arrays.<Object> asList(2, 3)));
|
||||
Assert.assertEquals(2, SQLEvalVisitorUtils.evalExpr(JdbcUtils.MYSQL, "? / ?", Arrays.<Object> asList(6, 3)));
|
||||
}
|
||||
|
||||
public void test_evalExpr_3() throws Exception {
|
||||
Assert.assertEquals(5.0f, SQLEvalVisitorUtils.evalExpr(JdbcUtils.MYSQL, "? + ?", "2.0", 3));
|
||||
Assert.assertEquals(6.0f, SQLEvalVisitorUtils.evalExpr(JdbcUtils.MYSQL, "? * ?", "2.0", 3));
|
||||
Assert.assertEquals(-1.0f, SQLEvalVisitorUtils.evalExpr(JdbcUtils.MYSQL, "? - ?", "2.0", 3));
|
||||
Assert.assertEquals(2.0f, SQLEvalVisitorUtils.evalExpr(JdbcUtils.MYSQL, "? / ?", "6.0", 3));
|
||||
}
|
||||
|
||||
public void test_add() throws Exception {
|
||||
Assert.assertEquals(5, SQLEvalVisitorUtils.evalExpr(JdbcUtils.MYSQL, "? + ?", Arrays.<Object> asList(2, 3)));
|
||||
|
||||
@@ -53,4 +53,37 @@ public class MySqlCreateTableTest extends MysqlTest {
|
||||
|
||||
// Assert.assertTrue(visitor.getColumns().contains(new Column("mytable", "last_name")));
|
||||
}
|
||||
|
||||
|
||||
public void test_1() throws Exception {
|
||||
String sql = "CREATE TABLE `ins_ebay_auth` ("
|
||||
+ " `auth_id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键id',"
|
||||
+ " `usr_id` int(10) NOT NULL COMMENT '外键,用户表',"
|
||||
+ " `status` char(1) COLLATE utf8_bin NOT NULL COMMENT '状态 0.有效?1.无效',"
|
||||
+ " `ebay_token` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'eBay授权码',"
|
||||
+ " `ebay_name` varchar(50) COLLATE utf8_bin NOT NULL COMMENT 'eBay唯一名',"
|
||||
+ " `create_time` datetime NOT NULL COMMENT '授权时间', "
|
||||
+ " `invalid_time` datetime NOT NULL COMMENT '授权失效时间',"
|
||||
+ " PRIMARY KEY (`auth_id`)"
|
||||
+ " ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='INS_EBAY_AUTH'";
|
||||
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
List<SQLStatement> statementList = parser.parseStatementList();
|
||||
SQLStatement statemen = statementList.get(0);
|
||||
print(statementList);
|
||||
|
||||
Assert.assertEquals(1, statementList.size());
|
||||
|
||||
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
|
||||
statemen.accept(visitor);
|
||||
|
||||
System.out.println("Tables : " + visitor.getTables());
|
||||
System.out.println("fields : " + visitor.getColumns());
|
||||
System.out.println("coditions : " + visitor.getConditions());
|
||||
System.out.println("orderBy : " + visitor.getOrderByColumns());
|
||||
|
||||
Assert.assertEquals(1, visitor.getTables().size());
|
||||
Assert.assertEquals(7, visitor.getColumns().size());
|
||||
Assert.assertEquals(0, visitor.getConditions().size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,15 @@ public class SQLUtilsTest extends TestCase {
|
||||
"\nFROM t" + //
|
||||
"\nWHERE id = 'abc'", formattedSql);
|
||||
}
|
||||
|
||||
public void test_format_1() throws Exception {
|
||||
String sql = "select * from t where tname LIKE \"%\"'温'\"%\"";
|
||||
String formattedSql = SQLUtils.formatMySql(sql);
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE tname LIKE CONCAT('%', '温', '%')", formattedSql);
|
||||
}
|
||||
|
||||
public void test_format_2() throws Exception {
|
||||
String sql = "begin\n" + " if (a=10) then\n" + " null;\n" + " else\n" + " null;\n" + " end if;\n" + "end;";
|
||||
System.out.println(SQLUtils.formatOracle(sql));
|
||||
}
|
||||
}
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.bvt.sql.mysql.visitor;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
public class MySqlParameterizedOutputVisitorTest extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
String sql = "SELECT appsheetserialno FROM app_trans WHERE nodeid = _gbk '619' "
|
||||
+ " AND alino = _gbk '2013110900031031001700thfund00163619'"
|
||||
+ " AND apserialno = _gbk '201405120002300002170013205458'";
|
||||
System.out.println(ParameterizedOutputVisitorUtils.parameterize(sql, "mysql"));
|
||||
System.out.println("-----------------------");
|
||||
|
||||
sql = "SELECT p.AppId, p.PlayerId, p.Nickname, p.CreateTime FROM acc_playeruser AS pu INNER JOIN acc_player AS p ON (pu.AppId = p.AppId AND pu.PlayerId = p.PlayerId) WHERE pu.UserId=x'881A58F6204D4E048F66E41596A66A57';";
|
||||
System.out.println(ParameterizedOutputVisitorUtils.parameterize(sql, "mysql"));
|
||||
System.out.println("-----------------------");
|
||||
|
||||
sql = "SET @now := NOW(); INSERT characters (uid, name, race, career, sex, creation) VALUES (4068548, '', 58, 0, 0, @now); SET @id := LAST_INSERT_ID(); INSERT characters_data (character_id, data, creation) VALUES (@id, '\0\0\0\0\0\0\0\04068548\0\0\0:\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<\0\0\0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0d\0\0\0__\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', @now); SELECT @id; ";
|
||||
System.out.println(ParameterizedOutputVisitorUtils.parameterize(sql, "mysql"));
|
||||
System.out.println("-----------------------");
|
||||
|
||||
sql = "INSERT INTO qrtz_JOB_DETAILS (SCHED_NAME, JOB_NAME, JOB_GROUP, DESCRIPTION, JOB_CLASS_NAME, IS_DURABLE, IS_NONCONCURRENT, IS_UPDATE_DATA, REQUESTS_RECOVERY, JOB_DATA) VALUES('DefaultQuartzScheduler', 'taobao.item.recommend.delete_368815794_2_35391685928', 'tasks', null, 'cn.agooo.job.TasksJob', 0, 0, 0, 0, x'ACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000017400077461736B7349647372000E6A6176612E6C616E672E4C6F6E673B8BE490CC8F23DF0200014A000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B020000787000000000002063227800')";
|
||||
System.out.println(ParameterizedOutputVisitorUtils.parameterize(sql, "mysql"));
|
||||
System.out.println("-----------------------");
|
||||
|
||||
sql = "SELECT * FROM sync_contactsdata WHERE __id=x'2EEE5AE7CB0E4AF697D966AE8BF046B8'";
|
||||
System.out.println(ParameterizedOutputVisitorUtils.parameterize(sql, "mysql"));
|
||||
System.out.println("-----------------------");
|
||||
|
||||
sql = "select TID,POSTFEE,RECEIVERADDRESS from tradegroup003 where (0 = 650954981082695 or tid=650954981082695) And SELLERNICK='______________' And BUYERNICK='yingge7' and CREATED > date_sub(now(), interval 48 hour) and STATUS = 'WAIT_BUYER_PAY' and func_isNotFollowgroup003(tradegroup003.tid,'______________') = 0";
|
||||
System.out.println(ParameterizedOutputVisitorUtils.parameterize(sql, "mysql"));
|
||||
System.out.println("-----------------------");
|
||||
|
||||
sql = "SHOW COLUMNS FROM `pms_purchase_ops`/*20140512152820##%2Fbase.php%3Fshopid%3D%26module%3Dpms%26action%3DqualityItem%26op_id%3D756%26params%3Dcase%253Aupdate%252Ctable%253Aquality%252Corder_id%253A201405090006DL%252Creceive_no%253AQCI01201405090006DL%252Creceive_treat%253AALL_DONE%260.5652460628381133*/;";
|
||||
System.out.println(ParameterizedOutputVisitorUtils.parameterize(sql, "mysql"));
|
||||
System.out.println("-----------------------");
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
String sql = "create or replace view vtmp_log_node_204180 as select `twf_log_group_user`.`uni_id` as `user_id`, `twf_log_group_user`.`control_group_type` from `twf_log_group_user` where `twf_log_group_user`.`subjob_id` = 204180";
|
||||
System.out.println(ParameterizedOutputVisitorUtils.parameterize(sql, JdbcConstants.MYSQL));
|
||||
System.out.println("-----------------------");
|
||||
|
||||
sql = " create view V_CustomerGoodsNf as select a.*,b.GoodsNO,b.GoodsName,b.SpecName,c.CustomerName,c.NickName,c.Tel,c.Email, StatusExt = (CASE a.curStatus WHEN (0) THEN ('待通知') WHEN (1) THEN ('已通知') WHEN (2) THEN ('已过期') WHEN (3) THEN ('被取消')END) from G_Customer_GoodsNotify a left outer join V_GoodsListBySpec b on a.GoodsID=b.GoodsID and a.SpecID=b.SpecID left outer join G_Customer_CustomerList c on a.CustomerID=c.CustomerID";
|
||||
System.out.println(ParameterizedOutputVisitorUtils.parameterize(sql, JdbcConstants.SQL_SERVER));
|
||||
System.out.println("-----------------------");
|
||||
|
||||
sql = "CREATE view V_API_GoodsMatch as SELECT a.SpecName, a.GoodsNO, a.GoodsName, bMatch = CONVERT(bit, (CASE isnull(b.Numiid, '') WHEN ('') THEN (0) ELSE (1) END)), issys1 = (CASE isnull(b.issys, '') WHEN ('') THEN ('无') WHEN (0) THEN ('未同步') WHEN (1) THEN ('待同步') WHEN (2) THEN ('同步失败') WHEN (3) THEN ('同步成功') END), bFixNum = isnull(b.bFixNum, 0), bVirNum = isnull(b.bVirNum, 0), issys = isnull(b.issys, 0), FixNum = isnull(b.FixNum, 0), VirNumBase = isnull(b.VirNumBase, 0), VirNumInc = isnull(b.VirNumInc, 0), b.TBName, b.TBSku, b.UpdateTime, b.syscount, b.sysLog, c.ShopName, b.TBOuterID, b.SKUOuterID, d .FlagName, b.GoodsID, b.SpecID, b.Numiid, b.Skuid, b.BTBGoods, b.sysGoodsType, b.ID, bstop = CONVERT(bit, isnull(b.bstop, 0)), b.bSingletb, b.SingleNumPer, b.VirNumTop, isnull(b.goodstype, '0') AS goodstype, CASE b.SpecID WHEN - 2 THEN 1 ELSE 0 END AS pcbs FROM V_GoodsSpec a LEFT OUTER JOIN G_API_SysMatch b ON a.GoodsID = b.GoodsID AND CASE b.SpecID WHEN - 2 THEN 1 ELSE a.specid END = CASE b.SpecID WHEN - 2 THEN 1 ELSE b.SpecID END AND b.GoodsType = 0 LEFT OUTER JOIN G_Cfg_ShopList c ON b.ShopID = c.ShopID LEFT OUTER JOIN dbo.G_Cfg_RecordFlag d ON a.FlagID = d .FlagID UNION ALL SELECT '' AS SpecName, a.GoodsNO, a.GoodsName, bMatch = CONVERT(bit, (CASE isnull(b.Numiid, '') WHEN ('') THEN (0) ELSE (1) END)), issys1 = (CASE isnull(b.issys, '') WHEN ('') THEN ('无') WHEN (0) THEN ('未同步') WHEN (1) THEN ('待同步') WHEN (2) THEN ('同步失败') WHEN (3) THEN ('同步成功') END), bFixNum = isnull(b.bFixNum, 0), bVirNum = isnull(b.bVirNum, 0), issys = isnull(b.issys, 0), FixNum = isnull(b.FixNum, 0), VirNumBase = isnull(b.VirNumBase, 0), VirNumInc = isnull(b.VirNumInc, 0), b.TBName, b.TBSku, b.UpdateTime, b.syscount, b.sysLog, c.ShopName, b.TBOuterID, b.SKUOuterID, '' AS FlagName, b.GoodsID, b.SpecID, b.Numiid, b.Skuid, b.BTBGoods, b.sysGoodsType, b.ID, bstop = CONVERT(bit, isnull(b.bstop, 0)), b.bSingletb, b.SingleNumPer, b.VirNumTop, b.goodstype, 0 AS pcbs FROM g_goods_goodslistfit a LEFT OUTER JOIN g_api_sysma";
|
||||
System.out.println(ParameterizedOutputVisitorUtils.parameterize(sql, JdbcConstants.SQL_SERVER));
|
||||
System.out.println("-----------------------");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.alibaba.druid.bvt.sql.oracle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.sql.OracleTest;
|
||||
import com.alibaba.druid.sql.SQLUtils;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleSchemaStatVisitor;
|
||||
import com.alibaba.druid.stat.TableStat;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
public class OracleListAggTest extends OracleTest {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
String sql = "SELECT prod_id, LISTAGG(cust_first_name||' '||cust_last_name, '; ') \n" //
|
||||
+ " WITHIN GROUP (ORDER BY amount_sold DESC) cust_list\n" //
|
||||
+ "FROM sales, customers\n" //
|
||||
+ "WHERE sales.cust_id = customers.cust_id AND cust_gender = 'M' \n" //
|
||||
+ " AND cust_credit_limit = 15000 AND prod_id BETWEEN 15 AND 18 \n" //
|
||||
+ " AND channel_id = 2 AND time_id > '01-JAN-01'\n" //
|
||||
+ "GROUP BY prod_id;";
|
||||
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
List<SQLStatement> statementList = parser.parseStatementList();
|
||||
SQLStatement stmt = statementList.get(0);
|
||||
print(statementList);
|
||||
|
||||
Assert.assertEquals(1, statementList.size());
|
||||
|
||||
Assert.assertEquals("SELECT prod_id, LISTAGG(cust_first_name || ' ' || cust_last_name, '; ') WITHIN GROUP (ORDER BY amount_sold DESC) AS cust_list" //
|
||||
+ "\nFROM sales, customers"//
|
||||
+ "\nWHERE sales.cust_id = customers.cust_id" //
|
||||
+ "\n\tAND cust_gender = 'M'" //
|
||||
+ "\n\tAND cust_credit_limit = 15000" //
|
||||
+ "\n\tAND prod_id BETWEEN 15 AND 18" //
|
||||
+ "\n\tAND channel_id = 2" //
|
||||
+ "\n\tAND time_id > '01-JAN-01'" //
|
||||
+ "\nGROUP BY prod_id",//
|
||||
SQLUtils.toSQLString(stmt, JdbcConstants.ORACLE));
|
||||
|
||||
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
|
||||
stmt.accept(visitor);
|
||||
|
||||
System.out.println("Tables : " + visitor.getTables());
|
||||
System.out.println("fields : " + visitor.getColumns());
|
||||
System.out.println("coditions : " + visitor.getConditions());
|
||||
System.out.println("relationships : " + visitor.getRelationships());
|
||||
|
||||
Assert.assertEquals(2, visitor.getTables().size());
|
||||
Assert.assertEquals(10, visitor.getColumns().size());
|
||||
|
||||
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("sales")));
|
||||
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("customers")));
|
||||
|
||||
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("sales", "cust_id")));
|
||||
Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("customers", "cust_id")));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user