fix storage SQL: авычки...

This commit is contained in:
AKurakin 2022-08-12 15:39:06 +03:00
parent 6ad470b67f
commit e44435b54d

View file

@ -39,12 +39,12 @@ public class DbUtilsHelper {
public static String createUpdateOrInsert(String tableName, String[] fields, String matchingKey) {
String updateOrInsert = "INSERT INTO " + tableName +
" (" + Arrays.stream(fields).map(f -> "\"" + f.toUpperCase() + "\"").collect(Collectors.joining(", ")) + ") values (" +
" (" + Arrays.stream(fields).map(f -> "" + f.toUpperCase() + "").collect(Collectors.joining(", ")) + ") values (" +
// Arrays.stream(fields).map(f -> "\"" + f.toUpperCase() + "\"").collect(Collectors.joining(", ", ":", ""));
String.join(", ", Collections.nCopies(fields.length, "?")) +
") ON CONFLICT ";
updateOrInsert += "(" + matchingKey.toUpperCase()+")";
updateOrInsert += " DO UPDATE SET " + Arrays.stream(fields).filter(f->!matchingKey.equalsIgnoreCase(f)).map(f -> "\"" + f.toUpperCase() + "\"=EXCLUDED.\"" + f.toUpperCase() + "\"").collect(Collectors.joining(", "));
updateOrInsert += " DO UPDATE SET " + Arrays.stream(fields).filter(f->!matchingKey.equalsIgnoreCase(f)).map(f -> "" + f.toUpperCase() + "=EXCLUDED." + f.toUpperCase() + "").collect(Collectors.joining(", "));
return updateOrInsert;
}