将Couchbase DB的n1ql查询输出中的数字转换为字符串

将Couchbase DB的n1ql查询输出中的数字转换为字符串,couchbase,tostring,data-conversion,n1ql,Couchbase,Tostring,Data Conversion,N1ql,在Couchbase DB的N1QL查询输出中,我需要以下值作为字符串 当前- "cas": 1499937943452123136 预期- "cas": "1499937943452123136" Cbq查询: select meta().cas from sampledb where type = "PROD" and Id = "PROD_101" 请求您的帮助。使用to_string函数 select to_string(meta().cas) from sampledb whe

在Couchbase DB的N1QL查询输出中,我需要以下值作为字符串

当前-

"cas": 1499937943452123136
预期-

"cas": "1499937943452123136"
Cbq查询:

select meta().cas from sampledb where type = "PROD" and Id = 
"PROD_101"

请求您的帮助。

使用to_string函数

select to_string(meta().cas) from sampledb where type = "PROD" and Id = "PROD_101"

您使用的是什么版本的Couchbase

要将字符串转换为数字,请使用如下示例所示的To_String()方法

如果要将字符串转换为数字,请使用如下示例所示的方法

查询:

select sum(TONUMBER(installmentPremium)) TotalInstallmentPremium  from data
where installmentPremium > "10" and type_="ProductComponentOption" limit 100;
[
  {
    "TotalInstallmentPremium": 15757.470000000001
  }
]
结果:

select sum(TONUMBER(installmentPremium)) TotalInstallmentPremium  from data
where installmentPremium > "10" and type_="ProductComponentOption" limit 100;
[
  {
    "TotalInstallmentPremium": 15757.470000000001
  }
]

您好@kbinstance,结果现在是一个字符串,但它已经舍入了最后2位。输出为“cas”:“149997943452123100”。但我需要的值是“cas”:“149997943452123136”。当TO_字符串参数超过某些值并指定给float时,它将丢失精度。这在功能版本中已修复。@Emraan:正如vsr所说,这是一个已知的问题,在即将发布的5.0测试版中已修复。