From 19595863894a762b42fe7d6226835aacf207dcb6 Mon Sep 17 00:00:00 2001 From: Koji Kawamura Date: Wed, 3 Jan 2018 09:03:14 +0900 Subject: [PATCH] NIFI-4729: This closes #2366. ConvertJSONToSQL converted boolean values in reverse Signed-off-by: joewitt --- .../org/apache/nifi/processors/standard/ConvertJSONToSQL.java | 2 +- .../apache/nifi/processors/standard/TestConvertJSONToSQL.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ConvertJSONToSQL.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ConvertJSONToSQL.java index 638ec9dc5c..9705dc0954 100755 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ConvertJSONToSQL.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ConvertJSONToSQL.java @@ -547,7 +547,7 @@ public class ConvertJSONToSQL extends AbstractProcessor { case Types.NUMERIC: if (fieldNode.isBoolean()) { // Convert boolean to number representation for databases those don't support boolean type. - fieldValue = fieldNode.asBoolean() ? "0" : "1"; + fieldValue = fieldNode.asBoolean() ? "1" : "0"; } break; diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertJSONToSQL.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertJSONToSQL.java index 8a03a81078..26f04a2601 100755 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertJSONToSQL.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestConvertJSONToSQL.java @@ -205,9 +205,8 @@ public class TestConvertJSONToSQL { out.assertAttributeEquals("sql.args.1.value", "1"); out.assertAttributeEquals("sql.args.2.type", String.valueOf(java.sql.Types.VARCHAR)); out.assertAttributeEquals("sql.args.2.value", "Bool"); - // Boolean value 'true' is converted to '0' out.assertAttributeEquals("sql.args.3.type", String.valueOf(java.sql.Types.INTEGER)); - out.assertAttributeEquals("sql.args.3.value", "0"); + out.assertAttributeEquals("sql.args.3.value", "1"); out.assertContentEquals("INSERT INTO PERSONS (ID, NAME, CODE) VALUES (?, ?, ?)"); }