1
1
/**
2
- * Copyright 2009-2017 the original author or authors.
2
+ * Copyright 2009-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
18
18
import java .io .IOException ;
19
19
import java .util .ArrayList ;
20
20
import java .util .Arrays ;
21
+ import java .util .Collections ;
21
22
import java .util .List ;
22
23
23
24
/**
@@ -62,7 +63,7 @@ public T INSERT_INTO(String tableName) {
62
63
63
64
public T VALUES (String columns , String values ) {
64
65
sql ().columns .add (columns );
65
- sql ().values .add (values );
66
+ sql ().values .add (Collections . singletonList ( values ) );
66
67
return getSelf ();
67
68
}
68
69
@@ -78,7 +79,7 @@ public T INTO_COLUMNS(String... columns) {
78
79
* @since 3.4.2
79
80
*/
80
81
public T INTO_VALUES (String ... values ) {
81
- sql ().values .addAll (Arrays .asList (values ));
82
+ sql ().values .add (Arrays .asList (values ));
82
83
return getSelf ();
83
84
}
84
85
@@ -326,7 +327,7 @@ public enum StatementType {
326
327
List <String > orderBy = new ArrayList <String >();
327
328
List <String > lastList = new ArrayList <String >();
328
329
List <String > columns = new ArrayList <String >();
329
- List <String > values = new ArrayList <String >();
330
+ List <List < String >> values = new ArrayList <>();
330
331
boolean distinct ;
331
332
332
333
public SQLStatement () {
@@ -382,7 +383,13 @@ private void joins(SafeAppendable builder) {
382
383
private String insertSQL (SafeAppendable builder ) {
383
384
sqlClause (builder , "INSERT INTO" , tables , "" , "" , "" );
384
385
sqlClause (builder , "" , columns , "(" , ")" , ", " );
385
- sqlClause (builder , "VALUES" , values , "(" , ")" , ", " );
386
+ for (int i = 0 ; i < values .size (); i ++) {
387
+ if (i == 0 ){
388
+ sqlClause (builder , "VALUES" , values .get (0 ), "(" , ")" , ", " );
389
+ }else {
390
+ sqlClause (builder , "," , values .get (i ), "(" , ")" , ", " );
391
+ }
392
+ }
386
393
return builder .toString ();
387
394
}
388
395
0 commit comments