From c484dffbb8494b8a38f60ded6d359286d7df49d7 Mon Sep 17 00:00:00 2001 From: Jonathan Ellis Date: Sun, 19 Dec 2010 03:38:41 +0000 Subject: [PATCH] backport CASSANDRA-1866 from 0.7 git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.6@1050753 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/cassandra/thrift/ThriftValidation.java | 7 +++++++ test/system/test_server.py | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/cassandra/thrift/ThriftValidation.java b/src/java/org/apache/cassandra/thrift/ThriftValidation.java index 710733c1a2..8b0cb17945 100644 --- a/src/java/org/apache/cassandra/thrift/ThriftValidation.java +++ b/src/java/org/apache/cassandra/thrift/ThriftValidation.java @@ -133,6 +133,13 @@ public class ThriftValidation throw new InvalidRequestException("supercolumn may not be specified for standard CF " + column_path_or_parent.column_family); } } + if (cfType.equals("Super")) + { + if (column_path_or_parent.super_column == null && column_path_or_parent.column != null) + { + throw new InvalidRequestException("A column cannot be specified without specifying a super column for removal on super CF " + column_path_or_parent.column_family); + } + } if (column_path_or_parent.column != null) { validateColumns(tablename, column_path_or_parent.column_family, column_path_or_parent.super_column, Arrays.asList(column_path_or_parent.column)); diff --git a/test/system/test_server.py b/test/system/test_server.py index 92cffe1ef4..a56179dd8a 100644 --- a/test/system/test_server.py +++ b/test/system/test_server.py @@ -163,8 +163,8 @@ def _verify_super(supercf='Super1', key='key1'): def _expect_exception(fn, type_): try: r = fn() - except type_: - pass + except type_, e: + return e else: raise Exception('expected %s; got %s' % (type_.__name__, r)) @@ -712,6 +712,11 @@ class TestMutations(CassandraTester): Column(_i64(7), 'value7', 0)])] assert super_columns == super_columns_expected, super_columns + # shouldn't be able to specify a column w/o a super column for remove + cp = ColumnPath(column_family='Super1', column=_i64(6)) + e = _expect_exception(lambda: client.remove('Keyspace1', 'key1', cp, 5, ConsistencyLevel.ONE), InvalidRequestException) + assert e.why.find("column cannot be specified without") >= 0 + def test_super_cf_remove_supercolumn(self): _insert_simple() _insert_super()