You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by bl...@apache.org on 2017/01/30 09:27:34 UTC
cassandra git commit: Fix InsertUpdateIfConditionTest (follow up
12981)
Repository: cassandra
Updated Branches:
refs/heads/cassandra-3.11 77f0f6831 -> 3cf415279
Fix InsertUpdateIfConditionTest (follow up 12981)
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/3cf41527
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/3cf41527
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/3cf41527
Branch: refs/heads/cassandra-3.11
Commit: 3cf415279c171fe20802ad90f181eed7da04c58d
Parents: 77f0f68
Author: Benjamin Lerer <b....@gmail.com>
Authored: Mon Jan 30 10:24:31 2017 +0100
Committer: Benjamin Lerer <b....@gmail.com>
Committed: Mon Jan 30 10:27:05 2017 +0100
----------------------------------------------------------------------
.../apache/cassandra/cql3/ColumnCondition.java | 9 ++++++++-
.../operations/InsertUpdateIfConditionTest.java | 18 +++++++++---------
2 files changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/3cf41527/src/java/org/apache/cassandra/cql3/ColumnCondition.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/ColumnCondition.java b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
index 75a988e..5395a9b 100644
--- a/src/java/org/apache/cassandra/cql3/ColumnCondition.java
+++ b/src/java/org/apache/cassandra/cql3/ColumnCondition.java
@@ -884,7 +884,14 @@ public class ColumnCondition
if (condition.inValues == null)
{
Lists.Marker inValuesMarker = (Lists.Marker) condition.value;
- for (ByteBuffer buffer : ((Lists.Value)inValuesMarker.bind(options)).elements)
+ Terminal terminal = inValuesMarker.bind(options);
+ if (terminal == null)
+ throw new InvalidRequestException("Invalid null list in IN condition");
+
+ if (terminal == Constants.UNSET_VALUE)
+ throw new InvalidRequestException("Invalid 'unset' value in condition");
+
+ for (ByteBuffer buffer : ((Lists.Value)terminal).elements)
this.inValues.add(buffer);
}
else
http://git-wip-us.apache.org/repos/asf/cassandra/blob/3cf41527/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
index 2729b83..edbc818 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java
@@ -1969,31 +1969,31 @@ public class InsertUpdateIfConditionTest extends CQLTester
createTable("CREATE TABLE %s (k int PRIMARY KEY, v frozen<" + myType + "> )");
- Object v = userType(0, "abc");
+ Object v = userType("a", 0, "b", "abc");
execute("INSERT INTO %s (k, v) VALUES (?, ?)", 0, v);
// Does not apply
- assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", userType(1, "abc"), userType(0, "ac")),
+ assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", userType("a", 1, "b", "abc"), userType("a", 0, "b", "ac")),
row(false, v));
- assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", userType(1, "abc"), null),
+ assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", userType("a", 1, "b", "abc"), null),
row(false, v));
- assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", userType(1, "abc"), unset()),
+ assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", userType("a", 1, "b", "abc"), unset()),
row(false, v));
assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", null, null),
row(false, v));
assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", unset(), unset()),
row(false, v));
- assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN ?", list(userType(1, "abc"), userType(0, "ac"))),
+ assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN ?", list(userType("a", 1, "b", "abc"), userType("a", 0, "b", "ac"))),
row(false, v));
// Does apply
- assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", userType(0, "abc"), userType(0, "ac")),
+ assertRows(execute("UPDATE %s SET v = {a: 0, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", userType("a", 0, "b", "abc"), userType("a", 0, "b", "ac")),
row(true));
- assertRows(execute("UPDATE %s SET v = {a: 1, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", userType(0, "bc"), null),
+ assertRows(execute("UPDATE %s SET v = {a: 1, b: 'bc'} WHERE k = 0 IF v IN (?, ?)", userType("a", 0, "b", "bc"), null),
row(true));
- assertRows(execute("UPDATE %s SET v = {a: 1, b: 'ac'} WHERE k = 0 IF v IN (?, ?, ?)", userType(0, "bc"), unset(), userType(1, "bc")),
+ assertRows(execute("UPDATE %s SET v = {a: 1, b: 'ac'} WHERE k = 0 IF v IN (?, ?, ?)", userType("a", 0, "b", "bc"), unset(), userType("a", 1, "b", "bc")),
row(true));
- assertRows(execute("UPDATE %s SET v = {a: 0, b: 'abc'} WHERE k = 0 IF v IN ?", list(userType(1, "ac"), userType(0, "ac"))),
+ assertRows(execute("UPDATE %s SET v = {a: 0, b: 'abc'} WHERE k = 0 IF v IN ?", list(userType("a", 1, "b", "ac"), userType("a", 0, "b", "ac"))),
row(true));
assertInvalidMessage("Invalid null list in IN condition",