Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/main/java/net/sf/jsqlparser/statement/insert/Insert.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,19 @@ public String toString() {

if (itemsList != null) {
sql.append(itemsList);
}else {
if (useSelectBrackets) {
sql.append("(");
}
if (select != null) {
sql.append(select);
}
if (useSelectBrackets) {
sql.append(")");
}
}

if (useSelectBrackets) {
sql.append("(");
}
if (select != null) {
sql.append(select);
}
if (useSelectBrackets) {
sql.append(")");
}


if (useDuplicate){
sql.append(" ON DUPLICATE KEY UPDATE ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,25 +407,29 @@ public static String getStringList(List<?> list) {
* @return comma separated list of the elements in the list
*/
public static String getStringList(List<?> list, boolean useComma, boolean useBrackets) {
String ans = "";
StringBuilder ans=new StringBuilder();
// String ans = "";
String comma = ",";
if (!useComma) {
comma = "";
}
if (list != null) {
if (useBrackets) {
ans += "(";
ans.append("(");
// ans += "(";
}

for (int i = 0; i < list.size(); i++) {
ans += "" + list.get(i) + ((i < list.size() - 1) ? comma + " " : "");
ans.append(list.get(i)).append(((i < list.size() - 1) ? comma + " " : ""));
Copy link
Copy Markdown
Member

@wumpz wumpz Aug 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To construct valid comma lists the constructs are nearly always weird :). You could use a commalist generator method within Plainselect. Nevertheless it was not your statement but the older one I am refering to.

// ans += "" + list.get(i) + ((i < list.size() - 1) ? comma + " " : "");
}

if (useBrackets) {
ans += ")";
ans.append(")");
// ans += ")";
}
}

return ans;
return ans.toString();
}
}