You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "André Paris (JIRA)" <ji...@apache.org> on 2018/06/07 20:04:00 UTC
[jira] [Created] (CASSANDRA-14505) Removal of last element on a
List deletes the entire row
André Paris created CASSANDRA-14505:
---------------------------------------
Summary: Removal of last element on a List deletes the entire row
Key: CASSANDRA-14505
URL: https://issues.apache.org/jira/browse/CASSANDRA-14505
Project: Cassandra
Issue Type: Bug
Components: Core
Environment: * Java: 1.8.0_171
* SO Ubuntu: 18.04 LTS
* Cassandra: 3.11.2
Reporter: André Paris
Fix For: 3.11.x
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)}}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org