Hey guys,
I'm suspecting that I found a bug on ConvertJSONToSQL (just for DELETE
statements).
I was getting incomplete values for attributes like this:
sql.args.10.type 91
sql.args.10.value 2016
This field is a date type so the attributes should be like this:
sql.args.10.type 91
sql.args.10.value 2016-01-18
I haven't tested another data types/values because I was rushing.
I've changed fieldValue variable to use createSqlStringValue method on
ConvertJSONToSQL.java (like for INSERT and UPDATE statements), rebuild the
nar and it seems working now.
The small patch is attached to this email.
I'm not posting on the Devs Lists because I'm not sure what are the impacts
of this changes neither the correct path to submit bugs.
Thanks,
Alberto
--- /root/ConvertJSONToSQL-20170105-before-delete-patch.java 2018-01-05
21:20:24.031309162 -0200
+++
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ConvertJSONToSQL.java
2018-01-05 21:53:08.658887605 -0200
@@ -784,11 +784,8 @@
final Integer colSize = desc.getColumnSize();
final JsonNode fieldNode = rootNode.get(fieldName);
- if (!fieldNode.isNull()) {
- String fieldValue = fieldNode.asText();
- if (colSize != null && fieldValue.length() > colSize) {
- fieldValue = fieldValue.substring(0, colSize);
- }
+ if (!fieldNode.isNull()) {
+ String fieldValue = createSqlStringValue(fieldNode,
colSize, sqlType);
attributes.put(attributePrefix + ".args." + fieldCount +
".value", fieldValue);
}
}