Elffuss BraidHub

kikocis/java-driver public

Revert "Override toString for PreparedStatement and BoundStatement (JAVA-115)."

This reverts commit 2cca684fcacbd222fc1bfd98677f2336d3ce9b63.
Changesetfe8bf37013246ad946ad6eaeed26317b0cd597e90611766ea92917f0a2af46fe
Authorolim7t <omichallat+github@gmail.com> · 2014-09-05 17:52 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2014-09-05 17:52 +02:00
Parents9ec95e075f57

Browse the files at this changeset

4 files changed

modified driver-core/CHANGELOG.rst +0 −1
@@ -12,7 +12,6 @@
1212 - [improvement] Add ResultSet.wasApplied() for conditional queries (JAVA-358)
1313 - [bug] Fix negative HostConnectionPool open count (JAVA-349)
1414 - [improvement] Log more connection details at trace and debug levels (JAVA-436)
15-- [improvement] Override toString for PreparedStatement and BoundStatement (JAVA-115)
1615
1716 2.0.5:
1817 ------
modified driver-core/src/main/java/com/datastax/driver/core/BoundStatement.java +2 −30
@@ -21,14 +21,13 @@
2121 import java.nio.ByteBuffer;
2222 import java.util.*;
2323
24-import com.datastax.driver.core.ColumnDefinitions.Definition;
2524 import com.datastax.driver.core.exceptions.InvalidTypeException;
2625
2726 /**
2827 * A prepared statement with values bound to the bind variables.
2928 * <p>
3029 * Once values has been provided for the variables of the {@link PreparedStatement}
31- * it has been created from, such BoundStatement can be executed (through
30+ * it has been created from, such BoundStatement can be executed (through
3231 * {@link Session#execute(Statement)}).
3332 * <p>
3433 * The values of a BoundStatement can be set by either index or name. When
@@ -90,7 +89,7 @@
9089 * bound to a non-null value.
9190 *
9291 * @param name the name of the variable to check.
93- * @return whether the first occurrence of variable {@code name} has been
92+ * @return whether the first occurrence of variable {@code name} has been
9493 * bound to a non-null value.
9594 *
9695 * @throws IllegalArgumentException if {@code name} is not a prepared
@@ -992,33 +991,6 @@
992991 return this;
993992 }
994993
995- /**
996- * {@inheritDoc}
997- *
998- * Note that this implementation for {@code BoundStatement} is intended for debugging purposes. It deserializes the statement's variables,
999- * which could have a performance impact.
1000- */
1001- @Override
1002- public String toString() {
1003- StringBuilder builder = new StringBuilder("BoundStatement[");
1004- builder.append(statement.getQueryString());
1005- int i = 0;
1006- for (Definition definition : statement.getVariables()) {
1007- builder.append(", ");
1008- String name = definition.getName();
1009- DataType type = definition.getType();
1010- String value = type.codec().deserialize(values[i]).toString();
1011- if (value.length() > 50) {
1012- value = String.format("%s...[truncated %s of %d characters]",
1013- value.substring(0, 50), type.getName(), value.length());
1014- }
1015- builder.append(name + " = " + value);
1016- i += 1;
1017- }
1018- builder.append("]");
1019- return builder.toString();
1020- }
1021-
1022994 private ColumnDefinitions metadata() {
1023995 return statement.getVariables();
1024996 }
modified driver-core/src/main/java/com/datastax/driver/core/DefaultPreparedStatement.java +0 −5
@@ -175,9 +175,4 @@
175175 public PreparedId getPreparedId() {
176176 return preparedId;
177177 }
178-
179- @Override
180- public String toString() {
181- return "PreparedStatement[" + query + "]";
182- }
183178 }
modified driver-core/src/test/java/com/datastax/driver/core/PreparedStatementTest.java +0 −12
@@ -15,11 +15,8 @@
1515 */
1616 package com.datastax.driver.core;
1717
18-import java.nio.ByteBuffer;
1918 import java.util.*;
2019
21-import com.google.common.base.Strings;
22-
2320 import org.testng.annotations.Test;
2421 import static org.testng.Assert.assertEquals;
2522 import static org.testng.Assert.assertTrue;
@@ -411,13 +408,4 @@
411408 throw e;
412409 }
413410 }
414-
415- @Test(groups = "short")
416- public void toStringTest() {
417- PreparedStatement ps = session.prepare("INSERT INTO " + SIMPLE_TABLE2 + " (k, v) VALUES (?, ?)");
418- BoundStatement bs = ps.bind("key", Strings.repeat("a", 100));
419- assertEquals(ps.toString(), "PreparedStatement[INSERT INTO test2 (k, v) VALUES (?, ?)]");
420- assertEquals(bs.toString(), "BoundStatement[INSERT INTO test2 (k, v) VALUES (?, ?), "
421- + "k = key, v = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...[truncated varchar of 100 characters]]");
422- }
423411 }