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");
|
JSONArray columnOptionArray = options == null ? null : JSONUtilities.getArray(options, "columns");
|
||||||
|
|
||||||
final boolean trimColNames = options == null ? true
|
final boolean trimColNames = options == null ? false : JSONUtilities.getBoolean(options, "trimColumnNames", false);
|
||||||
: JSONUtilities.getBoolean(options, "trimColumnNames", false);
|
|
||||||
|
//logger.info("Trim Column Names::" + trimColNames);
|
||||||
int count = columnOptionArray.length();
|
int count = columnOptionArray.length();
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
@ -71,10 +71,13 @@ public class SqlCreateBuilder {
|
|||||||
String name = JSONUtilities.getString(columnOptions, "name", null);
|
String name = JSONUtilities.getString(columnOptions, "name", null);
|
||||||
String type = JSONUtilities.getString(columnOptions, "type", "VARCHAR");
|
String type = JSONUtilities.getString(columnOptions, "type", "VARCHAR");
|
||||||
String size = JSONUtilities.getString(columnOptions, "size", "");
|
String size = JSONUtilities.getString(columnOptions, "size", "");
|
||||||
|
//logger.info("Before Trim Column Names::" + name);
|
||||||
|
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
if(trimColNames) {
|
if(trimColNames) {
|
||||||
createSB.append(name.trim() + " ");
|
String trimmedCol = name.replaceAll("\\s", "");
|
||||||
|
createSB.append( trimmedCol + " ");
|
||||||
|
//logger.info("After Trim Column Names::" + name);
|
||||||
}else{
|
}else{
|
||||||
createSB.append(name + " ");
|
createSB.append(name + " ");
|
||||||
}
|
}
|
||||||
@ -134,5 +137,13 @@ public class SqlCreateBuilder {
|
|||||||
}
|
}
|
||||||
return createSQL;
|
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);
|
colOptionsMap.put("" + json.get("name"), json);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
final boolean trimColNames = options == null ? false : JSONUtilities.getBoolean(options, "trimColumnNames", false);
|
||||||
String colNamesWithSep = columns.stream()
|
String colNamesWithSep = null;
|
||||||
.collect(Collectors.joining(","));
|
if(trimColNames) {
|
||||||
|
colNamesWithSep = columns.stream().map(col -> col.replaceAll("\\s", "")).collect(Collectors.joining(","));
|
||||||
|
}else {
|
||||||
|
colNamesWithSep = columns.stream().collect(Collectors.joining(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
StringBuffer values = new StringBuffer();
|
StringBuffer values = new StringBuffer();
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user