Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-14505

Removal of last element on a List deletes the entire row

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Duplicate
    • Fix Version/s: None
    • Component/s: Legacy/Core
    • Labels:
      None
    • Environment:
      • Java: 1.8.0_171
      • SO: Ubuntu 18.04 LTS
      • Cassandra: 3.11.2 
    • Severity:
      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

            Activity

              People

              • Assignee:
                blerer Benjamin Lerer
                Reporter:
                andreparis André Paris
                Authors:
                Benjamin Lerer
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: