You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AgensGraph v1.2及以下版本中n.id转整数报错的解决咨询

AgensGraph v1.2及以下:解决toInteger(n.id)报function tointeger(jsonb) does not exist问题

原因

在AgensGraph v1.2及更早版本中,n.id返回的是JSONB类型的属性值,而非原生字符串。即便查询结果显示为字符串,底层类型仍是JSONB,调用toInteger()时会传入整个JSONB对象,导致函数参数不匹配报错。

解决方法

先通过->>操作符提取属性的文本值,再转换为整数:

有效查询语句

MATCH (n:artefact) RETURN toInteger(n->>'id') AS id_integer;

或使用等价的toInt():

MATCH (n:artefact) RETURN toInt(n->>'id') AS id_integer;

说明

  • n->>'id':从JSONB节点n中提取id的文本字符串,返回text类型。
  • toInteger()/toInt():接收字符串参数完成类型转换,规避了直接操作JSONB对象的问题。

内容的提问来源于stack exchange,提问作者Spatial Digger

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 20:31:08