Github user pvillard31 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/1464#discussion_r99665513
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ConvertJSONToSQL.java
---
@@ -420,7 +433,11 @@ private String generateInsert(final JsonNode rootNode,
final Map<String, String>
final StringBuilder sqlBuilder = new StringBuilder();
int fieldCount = 0;
- sqlBuilder.append("INSERT INTO ").append(tableName).append(" (");
+ sqlBuilder.append("INSERT INTO ");
+ if (quoteTableName)
sqlBuilder.append(schema.getQuotedIdentifierString());
--- End diff --
Quick remark: could you change to do it similarly to column names?
Something like:
````java
if(quoteTableName){
sqlBuilder.append(schema.getQuotedIdentifierString())
.append(tableName)
.append(schema.getQuotedIdentifierString());
} else {
sqlBuilder.append(tableName);
}
````
This way you avoid two if evaluations.
Also, since you are going to make a change, could you update this same
piece of code for column names to avoid the negation check in the if statement?
To have:
````java
if(escapeColumnNames){
sqlBuilder.append(schema.getQuotedIdentifierString())
.append(normalizedColName)
.append(schema.getQuotedIdentifierString());
} else {
sqlBuilder.append(normalizedColName);
}
````
I believe this is more efficient.
Otherwise, LGTM.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---