BuildQuery builds the arguments array for a DML event INSERT query. It returns the query string and the shared arguments array. Returns an error if the number of arguments differs from the number of table columns.
(args []interface{})
| 895 | // It returns the query string and the shared arguments array. |
| 896 | // Returns an error if the number of arguments differs from the number of table columns. |
| 897 | func (b *DMLInsertQueryBuilder) BuildQuery(args []interface{}) (string, []interface{}, error) { |
| 898 | if len(args) != b.tableColumns.Len() { |
| 899 | return "", nil, fmt.Errorf("args count differs from table column count in BuildDMLInsertQuery") |
| 900 | } |
| 901 | sharedArgs := make([]interface{}, 0, b.sharedColumns.Len()) |
| 902 | for _, column := range b.sharedColumns.Columns() { |
| 903 | tableOrdinal := b.tableColumns.Ordinals[column.Name] |
| 904 | arg := column.convertArg(args[tableOrdinal]) |
| 905 | sharedArgs = append(sharedArgs, arg) |
| 906 | } |
| 907 | return b.preparedStatement, sharedArgs, nil |
| 908 | } |
| 909 | |
| 910 | // DMLUpdateQueryBuilder can build UPDATE queries for DML events. |
| 911 | // It holds the prepared query statement so it doesn't need to be recreated every time. |