Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Duplicate
-
None
-
None
-
- Java: 1.8.0_171
- SO: Ubuntu 18.04 LTS
- Cassandra: 3.11.2
-
Normal
Description
The behavior of an element removal from a list by an UPDATE differs by how the row was created:
Given the table
CREATE TABLE table_test (
id int PRIMARY KEY,
list list<text>
)
If the row is created by an INSERT, the row remains after the UPDATE to remove the last element on the list:
cqlsh:ks_test> INSERT INTO table_test (id, list ) VALUES ( 1, ['foo']) ;
cqlsh:ks_test> SELECT * FROM table_test;
id | list
---+-------
1 | ['foo']
(1 rows)
cqlsh:ks_test> UPDATE table_test SET list = list - ['foo'] WHERE id=1;
cqlsh:ks_test> SELECT * FROM table_test;
id | list
---+-----
1 | null
(1 rows)
But, if the row is created by an UPDATE, the row is deleted after the UPDATE to remove the last element on the list:
cqlsh:ks_test> UPDATE table_test SET list = list + ['foo'] WHERE id=2;
cqlsh:ks_test> SELECT * FROM table_test;
id | list
---+--------
2 | ['foo']
(1 rows)
cqlsh:ks_test> UPDATE table_test SET list = list - ['foo'] WHERE id=2;
cqlsh:ks_test> SELECT * FROM table_test;
id | list
---+-----
(0 rows)
Thanks in advance.
Attachments
Issue Links
- duplicates
-
CASSANDRA-11805 Row deleted when value updated to null
- Resolved
- is related to
-
CASSANDRA-14478 Improve the documentation of UPDATE vs INSERT
- Open