diff --git a/CHANGES.txt b/CHANGES.txt index 7342354997..3243f4f22c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -25,6 +25,7 @@ dev * fix range queries against wrapped range (CASSANDRA-1781) * fix consistencylevel calculations for NetworkTopologyStrategy (CASSANDRA-1804) + * cli support index type enum names (CASSANDRA-1810) 0.7.0-rc1 diff --git a/src/java/org/apache/cassandra/cli/CliClient.java b/src/java/org/apache/cassandra/cli/CliClient.java index 5f38de1ccb..192ffa4ee9 100644 --- a/src/java/org/apache/cassandra/cli/CliClient.java +++ b/src/java/org/apache/cassandra/cli/CliClient.java @@ -1414,20 +1414,28 @@ public class CliClient extends CliUserHelp */ private IndexType getIndexTypeFromString(String indexTypeAsString) { - Integer indexTypeId; IndexType indexType; - try { - indexTypeId = new Integer(indexTypeAsString); + try + { + indexType = IndexType.findByValue(new Integer(indexTypeAsString)); } - catch (NumberFormatException e) { - throw new RuntimeException("Could not convert " + indexTypeAsString + " into Integer."); + catch (NumberFormatException e) + { + try + { + // if this is not an integer lets try to get IndexType by name + indexType = IndexType.valueOf(indexTypeAsString); + } + catch (IllegalArgumentException ie) + { + throw new RuntimeException("IndexType '" + indexTypeAsString + "' is unsupported."); + } } - indexType = IndexType.findByValue(indexTypeId); - - if (indexType == null) { - throw new RuntimeException(indexTypeAsString + " is unsupported."); + if (indexType == null) + { + throw new RuntimeException("IndexType '" + indexTypeAsString + "' is unsupported."); } return indexType; diff --git a/test/unit/org/apache/cassandra/cli/CliTest.java b/test/unit/org/apache/cassandra/cli/CliTest.java index 26f5082b23..6b74e78f35 100644 --- a/test/unit/org/apache/cassandra/cli/CliTest.java +++ b/test/unit/org/apache/cassandra/cli/CliTest.java @@ -36,7 +36,7 @@ public class CliTest extends CleanupHelper // please add new statements here so they could be auto-runned by this test. private String[] statements = { "use TestKeySpace;", - "create column family CF1 with comparator=UTF8Type and column_metadata=[{ column_name:world, validation_class:IntegerType, index_type:0, index_name:IdxName }, { column_name:world2, validation_class:LongType, index_type:0, index_name:LongIdxName}];", + "create column family CF1 with comparator=UTF8Type and column_metadata=[{ column_name:world, validation_class:IntegerType, index_type:0, index_name:IdxName }, { column_name:world2, validation_class:LongType, index_type:KEYS, index_name:LongIdxName}];", "set CF1[hello][world] = 123848374878933948398384;", "get CF1[hello][world];", "set CF1[hello][world2] = 15;",