[ 
https://issues.apache.org/jira/browse/CASSANDRA-14505?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

André Paris updated CASSANDRA-14505:
------------------------------------
    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.

  was:
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)}}

 

Thans in advance.


> 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
>            Priority: Major
>             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)}}
>  
> Thanks in advance.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to