Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public abstract class ApiDataTypeDefs {
new PrimitiveApiDataTypeDef(
ApiTypeName.COUNTER,
DataTypes.COUNTER,
new ApiSupportDef.Support(false, false, true, true, ApiSupportDef.Update.NONE),
// counter values cannot be used in a filter (no CQL codec to bind them), so filter is
// false to match actual support, see #2462
new ApiSupportDef.Support(false, false, true, false, ApiSupportDef.Update.NONE),
// we do not support the user creating anything with a counter type, but we accept if the
// DB says
new DefaultTypeBindingRules(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void canNotFilterOnFrozen() {

/**
* Data API support for counter column: CreateTable(False), Insert(false), Read(True),
* Filter(True)
* Filter(False)
*/
@Nested
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
Expand All @@ -161,6 +161,25 @@ public final void createDefaultTablesAndIndexes() {
assertThat(executeCqlStatement(createTable.build())).isTrue();
}

// Regression test for #2462: a counter column must report apiSupport.filter == false in the
// table description, because filtering on a counter is not actually supported (see
// filterCounter() below). Previously it incorrectly reported filter == true.
@Test
@Order(2)
public final void listTablesReportsCounterNotFilterable() {
var apiSupportPath =
"status.tables.find { it.name == '%s' }.definition.columns.counter.apiSupport"
.formatted(TABLE_COUNTER);
assertNamespaceCommand(keyspaceName)
.templated()
.listTables(true)
.wasSuccessful()
.body(apiSupportPath + ".createTable", is(false))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fragile and encourages copy-past coding, we would create assertion functions for this

.body(apiSupportPath + ".insert", is(false))
.body(apiSupportPath + ".read", is(true))
.body(apiSupportPath + ".filter", is(false));
}

// In Cassandra, you cannot use an INSERT statement directly for counters.
// Instead, counter columns require a special kind of update operation.
// Counters in Cassandra are designed to increment or decrement a value,
Expand Down