simonbence commented on a change in pull request #4350:
URL: https://github.com/apache/nifi/pull/4350#discussion_r444009133



##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutDatabaseRecord.java
##########
@@ -101,6 +106,7 @@
     static final String UPDATE_TYPE = "UPDATE";
     static final String INSERT_TYPE = "INSERT";
     static final String DELETE_TYPE = "DELETE";
+    static final String UPSERT_TYPE = "UPSERT";

Review comment:
       Minor: I think this is not a really widely known terminology. It might 
worth to think about UPDATE_OR_INSERT for better readability. (at least in 
variable name)

##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutDatabaseRecord.java
##########
@@ -29,6 +29,8 @@
 import org.apache.nifi.annotation.lifecycle.OnScheduled;

Review comment:
       Could you please extend  TestPutDatabaseRecord with relevant case?

##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/db/impl/PostgreSQLDatabaseAdapter.java
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.processors.standard.db.impl;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class PostgreSQLDatabaseAdapter extends GenericDatabaseAdapter {
+    @Override
+    public String getName() {
+        return "PostgreSQL";
+    }
+
+    @Override
+    public String getDescription() {
+        return "Generates PostgreSQL compatible SQL";
+    }
+
+    @Override
+    public boolean supportsUpsert() {
+        return true;
+    }
+
+    @Override
+    public String getUpsertStatement(String table, List<String> columnNames, 
Collection<String> uniqueKeyColumnNames) {
+        String columns = columnNames.stream()
+            .collect(Collectors.joining(", "));
+
+        String parameterizedInsertValues = columnNames.stream()
+            .map(__ -> "?")
+            .collect(Collectors.joining(", "));
+
+        String updateValues = columnNames.stream()

Review comment:
       Minor: updateColumns?

##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/db/impl/PostgreSQLDatabaseAdapter.java
##########
@@ -0,0 +1,68 @@
+/*

Review comment:
       Could you please add a test like TestMSSQLDatabaseAdapter?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to