提交 2d4dd6fd authored 作者: Thomas Mueller's avatar Thomas Mueller

Improve code coverage (remove unused code).

上级 d1c791cd
...@@ -15,7 +15,6 @@ import org.h2.engine.Session; ...@@ -15,7 +15,6 @@ import org.h2.engine.Session;
import org.h2.expression.ParameterInterface; import org.h2.expression.ParameterInterface;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.message.TraceObject;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
/** /**
...@@ -265,7 +264,7 @@ public abstract class Command implements CommandInterface { ...@@ -265,7 +264,7 @@ public abstract class Command implements CommandInterface {
} }
public String toString() { public String toString() {
return TraceObject.toString(sql, getParameters()); return sql + getParameters();
} }
public boolean isCacheable() { public boolean isCacheable() {
......
...@@ -14,7 +14,6 @@ import org.h2.expression.ParameterInterface; ...@@ -14,7 +14,6 @@ import org.h2.expression.ParameterInterface;
import org.h2.expression.ParameterRemote; import org.h2.expression.ParameterRemote;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.message.TraceObject;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
import org.h2.result.ResultRemote; import org.h2.result.ResultRemote;
import org.h2.util.New; import org.h2.util.New;
...@@ -245,7 +244,7 @@ public class CommandRemote implements CommandInterface { ...@@ -245,7 +244,7 @@ public class CommandRemote implements CommandInterface {
} }
public String toString() { public String toString() {
return TraceObject.toString(sql, getParameters()); return sql + getParameters();
} }
public int getCommandType() { public int getCommandType() {
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
*/ */
package org.h2.command.ddl; package org.h2.command.ddl;
import java.util.ArrayList;
import java.util.List;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.command.Prepared; import org.h2.command.Prepared;
import org.h2.command.dml.Query; import org.h2.command.dml.Query;
...@@ -16,14 +18,10 @@ import org.h2.engine.DbObject; ...@@ -16,14 +18,10 @@ import org.h2.engine.DbObject;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.expression.Parameter; import org.h2.expression.Parameter;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.message.TraceObject;
import org.h2.schema.Schema; import org.h2.schema.Schema;
import org.h2.table.Table; import org.h2.table.Table;
import org.h2.table.TableView; import org.h2.table.TableView;
import java.util.ArrayList;
import java.util.List;
/** /**
* This class represents the statement * This class represents the statement
* CREATE VIEW * CREATE VIEW
...@@ -108,7 +106,7 @@ public class CreateView extends SchemaCommand { ...@@ -108,7 +106,7 @@ public class CreateView extends SchemaCommand {
if (params != null && params.size() > 0) { if (params != null && params.size() > 0) {
throw DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1, "parameters in views"); throw DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1, "parameters in views");
} }
querySQL = TraceObject.toString(select.getPlanSQL(), select.getParameters()); querySQL = select.getPlanSQL();
} }
Session sysSession = db.getSystemSession(); Session sysSession = db.getSystemSession();
TableView view; TableView view;
......
...@@ -8,10 +8,7 @@ package org.h2.message; ...@@ -8,10 +8,7 @@ package org.h2.message;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Map; import java.util.Map;
import org.h2.expression.ParameterInterface;
import org.h2.util.StatementBuilder;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
/** /**
...@@ -358,18 +355,7 @@ public class TraceObject { ...@@ -358,18 +355,7 @@ public class TraceObject {
if (map.size() == 0) { if (map.size() == 0) {
return "new Map()"; return "new Map()";
} }
StringBuilder buff = new StringBuilder("new Map() /* "); return "new Map() /* " + map.toString() + " */";
try {
for (Map.Entry<String, Class <?>> entry : map.entrySet()) {
String key = entry.getKey();
Class<?> clazz = entry.getValue();
buff.append(key).append(':').append(clazz.getName());
}
} catch (Exception e) {
buff.append(e.toString()).append(": ").append(map.toString());
}
buff.append("*/");
return buff.toString();
} }
/** /**
...@@ -408,32 +394,4 @@ public class TraceObject { ...@@ -408,32 +394,4 @@ public class TraceObject {
} }
} }
/**
* INTERNAL
*/
public static String toString(String sql, ArrayList<? extends ParameterInterface> params) {
StatementBuilder buff = new StatementBuilder(sql);
if (params != null && params.size() > 0) {
buff.append(" {");
int i = 0;
for (ParameterInterface p : params) {
i++;
try {
buff.appendExceptFirst(", ");
buff.append(i).append(": ");
if (p == null || p.getParamValue() == null) {
buff.append('-');
} else {
buff.append(p.getParamValue().getSQL());
}
} catch (Exception e) {
buff.append("/* ").append(i).append(": ").append(e.toString()).append("*/ ");
}
}
buff.append("};");
}
return buff.toString();
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论