remove whitespaces between column names options
This commit is contained in:
parent
223d16db39
commit
3ffbcc9db7
@ -60,9 +60,9 @@ public class SqlCreateBuilder {
|
||||
|
||||
JSONArray columnOptionArray = options == null ? null : JSONUtilities.getArray(options, "columns");
|
||||
|
||||
final boolean trimColNames = options == null ? true
|
||||
: JSONUtilities.getBoolean(options, "trimColumnNames", false);
|
||||
|
||||
final boolean trimColNames = options == null ? false : JSONUtilities.getBoolean(options, "trimColumnNames", false);
|
||||
|
||||
//logger.info("Trim Column Names::" + trimColNames);
|
||||
int count = columnOptionArray.length();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
@ -71,10 +71,13 @@ public class SqlCreateBuilder {
|
||||
String name = JSONUtilities.getString(columnOptions, "name", null);
|
||||
String type = JSONUtilities.getString(columnOptions, "type", "VARCHAR");
|
||||
String size = JSONUtilities.getString(columnOptions, "size", "");
|
||||
|
||||
//logger.info("Before Trim Column Names::" + name);
|
||||
|
||||
if (name != null) {
|
||||
if(trimColNames) {
|
||||
createSB.append(name.trim() + " ");
|
||||
String trimmedCol = name.replaceAll("\\s", "");
|
||||
createSB.append( trimmedCol + " ");
|
||||
//logger.info("After Trim Column Names::" + name);
|
||||
}else{
|
||||
createSB.append(name + " ");
|
||||
}
|
||||
@ -134,5 +137,13 @@ public class SqlCreateBuilder {
|
||||
}
|
||||
return createSQL;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// String column = "Column 1 With Spaces";
|
||||
// String newCol = column.replaceAll("\\s", "");
|
||||
//
|
||||
// logger.info("Column after trim:" + newCol);
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -85,9 +85,15 @@ public class SqlInsertBuilder {
|
||||
colOptionsMap.put("" + json.get("name"), json);
|
||||
});
|
||||
}
|
||||
|
||||
String colNamesWithSep = columns.stream()
|
||||
.collect(Collectors.joining(","));
|
||||
final boolean trimColNames = options == null ? false : JSONUtilities.getBoolean(options, "trimColumnNames", false);
|
||||
String colNamesWithSep = null;
|
||||
if(trimColNames) {
|
||||
colNamesWithSep = columns.stream().map(col -> col.replaceAll("\\s", "")).collect(Collectors.joining(","));
|
||||
}else {
|
||||
colNamesWithSep = columns.stream().collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
|
||||
StringBuffer values = new StringBuffer();
|
||||
|
||||
int idx = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user