kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | fe8bf37013246ad946ad6eaeed26317b0cd597e90611766ea92917f0a2af46fe |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-09-05 17:52 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-09-05 17:52 +02:00 |
| Parents | 9ec95e075f57 |
4 files changed
modified driver-core/CHANGELOG.rst +0 −1
| @@ -12,7 +12,6 @@ | ||
| 12 | 12 | - [improvement] Add ResultSet.wasApplied() for conditional queries (JAVA-358) |
| 13 | 13 | - [bug] Fix negative HostConnectionPool open count (JAVA-349) |
| 14 | 14 | - [improvement] Log more connection details at trace and debug levels (JAVA-436) |
| 15 | -- [improvement] Override toString for PreparedStatement and BoundStatement (JAVA-115) | |
| 16 | 15 | |
| 17 | 16 | 2.0.5: |
| 18 | 17 | ------ |
modified driver-core/src/main/java/com/datastax/driver/core/BoundStatement.java +2 −30
| @@ -21,14 +21,13 @@ | ||
| 21 | 21 | import java.nio.ByteBuffer; |
| 22 | 22 | import java.util.*; |
| 23 | 23 | |
| 24 | -import com.datastax.driver.core.ColumnDefinitions.Definition; | |
| 25 | 24 | import com.datastax.driver.core.exceptions.InvalidTypeException; |
| 26 | 25 | |
| 27 | 26 | /** |
| 28 | 27 | * A prepared statement with values bound to the bind variables. |
| 29 | 28 | * <p> |
| 30 | 29 | * 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 | |
| 32 | 31 | * {@link Session#execute(Statement)}). |
| 33 | 32 | * <p> |
| 34 | 33 | * The values of a BoundStatement can be set by either index or name. When |
| @@ -90,7 +89,7 @@ | ||
| 90 | 89 | * bound to a non-null value. |
| 91 | 90 | * |
| 92 | 91 | * @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 | |
| 94 | 93 | * bound to a non-null value. |
| 95 | 94 | * |
| 96 | 95 | * @throws IllegalArgumentException if {@code name} is not a prepared |
| @@ -992,33 +991,6 @@ | ||
| 992 | 991 | return this; |
| 993 | 992 | } |
| 994 | 993 | |
| 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 | - | |
| 1022 | 994 | private ColumnDefinitions metadata() { |
| 1023 | 995 | return statement.getVariables(); |
| 1024 | 996 | } |
modified driver-core/src/main/java/com/datastax/driver/core/DefaultPreparedStatement.java +0 −5
| @@ -175,9 +175,4 @@ | ||
| 175 | 175 | public PreparedId getPreparedId() { |
| 176 | 176 | return preparedId; |
| 177 | 177 | } |
| 178 | - | |
| 179 | - @Override | |
| 180 | - public String toString() { | |
| 181 | - return "PreparedStatement[" + query + "]"; | |
| 182 | - } | |
| 183 | 178 | } |
modified driver-core/src/test/java/com/datastax/driver/core/PreparedStatementTest.java +0 −12
| @@ -15,11 +15,8 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | -import java.nio.ByteBuffer; | |
| 19 | 18 | import java.util.*; |
| 20 | 19 | |
| 21 | -import com.google.common.base.Strings; | |
| 22 | - | |
| 23 | 20 | import org.testng.annotations.Test; |
| 24 | 21 | import static org.testng.Assert.assertEquals; |
| 25 | 22 | import static org.testng.Assert.assertTrue; |
| @@ -411,13 +408,4 @@ | ||
| 411 | 408 | throw e; |
| 412 | 409 | } |
| 413 | 410 | } |
| 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 | - } | |
| 423 | 411 | } |