This is an automated email from the ASF dual-hosted git repository. ycai pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 68fd9abfe5186262ce1a2cabccd1af5bb2ef75fa Author: yifan-c <[email protected]> AuthorDate: Thu Jan 28 10:46:07 2021 -0800 test to demonstrate cqlsh DDL fails with the names --- .../apache/cassandra/tools/cqlsh/CqlshTest.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/unit/org/apache/cassandra/tools/cqlsh/CqlshTest.java b/test/unit/org/apache/cassandra/tools/cqlsh/CqlshTest.java index 4e6dd20..89ff055 100644 --- a/test/unit/org/apache/cassandra/tools/cqlsh/CqlshTest.java +++ b/test/unit/org/apache/cassandra/tools/cqlsh/CqlshTest.java @@ -18,6 +18,9 @@ package org.apache.cassandra.tools.cqlsh; +import java.util.Arrays; +import java.util.List; + import org.junit.BeforeClass; import org.junit.Test; @@ -28,6 +31,7 @@ import org.hamcrest.CoreMatchers; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class CqlshTest extends CQLTester { @@ -44,4 +48,29 @@ public class CqlshTest extends CQLTester assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("No keyspace has been specified")); assertEquals(2, tool.getExitCode()); } + + @Test + public void testUseUnreservedKeywordAsColumnName() + { + List<String> names = Arrays.asList("access", "datacenters"); + for (String name : names) + { + testUseUnreservedKeywordAsColumnName(name); + testUseUnreservedKeywordAsColumnName(name.toUpperCase()); + } + } + + private void testUseUnreservedKeywordAsColumnName(String unreservedKeyword) + { + String createTableFormat = "CREATE TABLE %s.\"test_%s\" ( foo text PRIMARY KEY, \"%s\" text);"; + ToolResult tool = ToolRunner.invokeCqlsh(String.format(createTableFormat, KEYSPACE_PER_TEST, unreservedKeyword, unreservedKeyword)); + assertCqlshNoStderr(tool); + assertEquals("Create table failed", 0, tool.getExitCode()); + } + + private static void assertCqlshNoStderr(ToolResult toolResult) + { + String stderr = toolResult.getCleanedStderr(); + assertTrue("Cqlsh failed: " + stderr, stderr.isEmpty()); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
