maedhroz commented on code in PR #1816:
URL: https://github.com/apache/cassandra/pull/1816#discussion_r959135863
##########
test/distributed/org/apache/cassandra/distributed/test/CASAddTest.java:
##########
@@ -62,6 +65,48 @@ public void testAddition() throws Throwable
}
}
+ @Test
+ public void testAdditionNotExists() throws Throwable
+ {
+ try (Cluster cluster = init(Cluster.create(3)))
+ {
+ cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int
PRIMARY KEY, a int, b text, undefined blob)");
+
+ // n = n + value where n = null
+ cluster.coordinator(1).execute("UPDATE " + KEYSPACE + ".tbl SET a
= a + 1, b = b + 'fail' WHERE pk = 1 IF undefined = NULL",
ConsistencyLevel.QUORUM);
Review Comment:
nit: If you don't want to resort to using the dummy blob, I think you could
rewrite like this:
```
cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int PRIMARY KEY,
a int, b text)");
// n = n + value where n = null
cluster.coordinator(1).execute("INSERT INTO " + KEYSPACE + ".tbl (pk) VALUES
(1)", ConsistencyLevel.QUORUM);
cluster.coordinator(1).execute("UPDATE " + KEYSPACE + ".tbl SET a = a + 1, b
= b + 'fail' WHERE pk = 1 IF EXISTS", ConsistencyLevel.QUORUM);
assertRows(cluster.coordinator(1).execute("SELECT * FROM " + KEYSPACE +
".tbl WHERE pk = 1", ConsistencyLevel.SERIAL), row(1, null, null));
...
// have cas add defaults when missing
cluster.coordinator(1).execute("UPDATE " + KEYSPACE + ".tbl SET a = a + 1, b
= b + 'success' WHERE pk = 1 IF EXISTS", ConsistencyLevel.QUORUM);
assertRows(cluster.coordinator(1).execute("SELECT * FROM " + KEYSPACE +
".tbl WHERE pk = 1", ConsistencyLevel.SERIAL), row(1, 1, "success"));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]