| 60 | } |
| 61 | |
| 62 | func (e *RowBatch) AsSQLQuery(schemaName, tableName string) (string, []interface{}, error) { |
| 63 | if err := verifyValuesHasTheSameLengthAsColumns(e.table, e.values...); err != nil { |
| 64 | return "", nil, err |
| 65 | } |
| 66 | |
| 67 | valuesStr := "(" + strings.Repeat("?,", len(e.columns)-1) + "?)" |
| 68 | valuesStr = strings.Repeat(valuesStr+",", len(e.values)-1) + valuesStr |
| 69 | |
| 70 | query := "INSERT IGNORE INTO " + |
| 71 | QuotedTableNameFromString(schemaName, tableName) + |
| 72 | " (" + strings.Join(QuoteFields(e.columns), ",") + ") VALUES " + valuesStr |
| 73 | |
| 74 | return query, e.flattenRowData(), nil |
| 75 | } |
| 76 | |
| 77 | func (e *RowBatch) flattenRowData() []interface{} { |
| 78 | rowSize := len(e.values[0]) |