node.jscassandradatastax-node-driver

How do I update a column with type map<boolean, int> correctly?


I have the following table in Cassandra:

CREATE TABLE my_table (
    id int,
    map_bool_int_col MAP<boolean, int>,
    PRIMARY KEY (id)
);

According to cassandra Node.js driver documentation I can use js object to update columns with map type.
So I tried to send the following query:

client.execute("UPDATE my_table SET map_bool_int_col = ? WHERE id = ?", [{"false": 1, "true": 2}, 1], {prepare: true});

After executing the code above the column has value

{true: 2}

, false key just disappeared.
I tried to send {false: 1, true: 2} object, the result is the same. I suppose because all object keys are still strings.
I kinda managed to update column with false values by sending this object {"": 1, "true": 2} - so it converts empty strings to false. But sending empty strings instead of boolean doesn't seem right.
Is there another way to update column with such type with false keys using cassandra nodejs driver?


Solution

  • There's something strange going on with the encoding of the map in this case. I've filed NODEJS-650 to look into this issue further.