【问题标题】:Cassandra: not able to update a map datatype in cqlCassandra:无法在 cql 中更新地图数据类型
【发布时间】:2019-01-25 07:03:18
【问题描述】:
CREATE TABLE IF NOT EXISTS  Social ("partitionId" text,"name" text,  "id"   text,  "data1" text, "data2" text,  "data3" map<text,text>, "data4 boolean, "data5" map<text, text>, primary key ("partitionId","name","id"));

const newValue = Object.values({
sId: '6e4d02ddc56bb014fee',
sData: '{"stamina":"yes"}',
rId: 'b1a264ed-b3ss9270316',
re: '101-r'
});

const q = 'UPDATE social SET "data5[?] = ? WHERE "partitionId" = \'social\' AND "id" = ? AND "name" = ?;';


client.execute(q, newValue, { prepare: true }).then(result => console.log(result.wasApplied()));

输出:

UnhandledPromiseRejectionWarning: ResponseError: Undefined column name data5 在 FrameReader.readError

我正在使用 nodejs cassandra 驱动程序来更新数据类型映射的列 data5,但我得到了上述错误。有人可以帮忙吗?

【问题讨论】:

    标签: node.js cassandra cqlsh


    【解决方案1】:

    我在几次尝试中找到了解决方案。 经过 Cassandra 文档的一些研究,我发现了这个:

    默认情况下,Cassandra 会将所有表/列名称转换为小写。如果需要区分大小写的表/列名,请将其括在双引号中。

    所以,我修改了我的查询:

    const q = 'UPDATE Social SET "data5"[?] = ? WHERE "partitionId" = \'router\' AND   "id" = ? AND "name" = ?;';
    

    它奏效了。

    【讨论】:

      猜你喜欢
      • 2018-08-25
      • 1970-01-01
      • 1970-01-01
      • 2014-10-22
      • 2012-02-11
      • 1970-01-01
      • 2020-11-22
      • 2020-05-31
      • 2012-02-26
      相关资源
      最近更新 更多