From 94650f6a0952d070da59479307a39efe8658b49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nadja=20M=C3=BCller?= <73830555+nadja-muller@users.noreply.github.com> Date: Sun, 8 Oct 2023 22:01:18 +0200 Subject: [PATCH] [NiLGknLU] add boolean example to apoc.refactor.normalizeAsBoolean (#3793) --- .../apoc.refactor.normalizeAsBoolean.adoc | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/docs/asciidoc/modules/ROOT/partials/usage/apoc.refactor.normalizeAsBoolean.adoc b/docs/asciidoc/modules/ROOT/partials/usage/apoc.refactor.normalizeAsBoolean.adoc index b7b3c7fd06..b2c035449e 100644 --- a/docs/asciidoc/modules/ROOT/partials/usage/apoc.refactor.normalizeAsBoolean.adoc +++ b/docs/asciidoc/modules/ROOT/partials/usage/apoc.refactor.normalizeAsBoolean.adoc @@ -5,11 +5,13 @@ The examples in this section are based on the following sample graph: CREATE (:Person {prop: 'Y', name:'A'}), (:Person {prop: 'Yes', name:'B'}), (:Person {prop: 'NO', name:'C'}), - (:Person {prop: 'X', name:'D'}); + (:Person {prop: 'X', name:'D'}), + (:Person {prop: true, name:'E'}), + (:Person {prop: false, name:'F'}); ---- We want to transform some properties into a boolean, `Y`, `Yes` into true and the properties `NO` into false. -The other properties that don't match these possibilities will be set as `null`. +The other properties that don't match these possibilities will be set as `null`. This includes `BOOLEAN` values as well. .The following normalizes all applicable boolean values for all nodes that have the `prop` property: [source,cypher] @@ -25,8 +27,31 @@ RETURN n.name AS name, n.prop AS prop; [opts="header"] |=== | name | prop -| "A" | TRUE -| "B" | TRUE -| "C" | FALSE -| "D" | NULL +| "A" | true +| "B" | true +| "C" | false +| "D" | null +| "E" | null +| "F" | null +|=== + +If you want to keep `BOOLEAN` values as they are, include them in the parameters `trueValues` and `falseValues`: +---- +MATCH (n) +CALL apoc.refactor.normalizeAsBoolean(n,'prop',['Y','Yes', true],['NO', false]) +WITH n +ORDER BY n.id +RETURN n.name AS name, n.prop AS prop; +---- + +.Results +[opts="header"] +|=== +| name | prop +| "A" | true +| "B" | true +| "C" | false +| "D" | null +| "E" | true +| "F" | false |=== \ No newline at end of file