Neo4j apoc.cypher.doit 产量成功但产量旧/以前的值

问题描述 投票:0回答:1

我正在运行一个动态查询,我在其中输入包含秘密的属性列表并从某些节点中删除秘密值。查询成功运行,这意味着它遍历属性列表并删除这些属性值。但是,当产生结果时,一组属性显示旧的/以前的值。当我在这些节点上运行单独的只读查询时,我看到值确实已更新。我做错了什么吗?

这是属性名称的动态列表:

:params { secretProps: ['semiSecret','superSecret'] }

这是密码声明:

Unwind $secretProps as prop
With prop
CALL apoc.cypher.doIt('Match (h:History) Where h.'+prop+' Is Not Null Set h.'+prop+' = "[Removed]" Return h;', {}) Yield value
Return value;

从上面的语句返回的节点似乎仍然包含其中一个秘密:

  {
    "value": {
      "h": {
        "identity": 7040,
        "labels": [
          "History"
        ],
        "properties": {
          "semiSecret": "[Removed]",
          "superSecret": "Oops, this is secret!"
        },
        "elementId": "7040"
      }
    }
  }

然而,当我再次检查...

Match (h:History) Where h.superSecret Is Not Null Return h;

...两个秘密都被删除了:

  {
    "value": {
      "h": {
        "identity": 7040,
        "labels": [
          "History"
        ],
        "properties": {
          "semiSecret": "[Removed]",
          "superSecret": "[Removed]"
        },
        "elementId": "7040"
      }
    }
  }
neo4j cypher neo4j-apoc
1个回答
0
投票

您的查询正在返回每次

value
调用返回的
apoc.cypher.doIt
,并且每次调用一次只更改一个属性。

所以,返回的第一个

value
只会替换'semiSecret'道具。而返回的第二个
value
将更换两个道具。

所以,要么寻找返回的最后一个

value
,要么这样做只看到最后一个
value

UNWIND $secretProps as prop
WITH prop
CALL apoc.cypher.doIt('MATCH (h:History) WHERE h.'+prop+' IS NOT NULL SET h.'+prop+' = "[Removed]" Return h;', {}) YIELD value
RETURN value
SKIP SIZE($secretProps)-1;
© www.soinside.com 2019 - 2024. All rights reserved.