MCPcopy
hub / github.com/github/gh-ost / BuildQuery

Method BuildQuery

go/sql/builder.go:835–846  ·  view source on GitHub ↗

BuildQuery builds the arguments array for a DML event DELETE query. It returns the query string and the unique key arguments array. Returns an error if the number of arguments is not equal to the number of table columns.

(args []interface{})

Source from the content-addressed store, hash-verified

833// It returns the query string and the unique key arguments array.
834// Returns an error if the number of arguments is not equal to the number of table columns.
835func (b *DMLDeleteQueryBuilder) BuildQuery(args []interface{}) (string, []interface{}, error) {
836 if len(args) != b.tableColumns.Len() {
837 return "", nil, fmt.Errorf("args count differs from table column count in BuildDMLDeleteQuery")
838 }
839 uniqueKeyArgs := make([]interface{}, 0, b.uniqueKeyColumns.Len())
840 for _, column := range b.uniqueKeyColumns.Columns() {
841 tableOrdinal := b.tableColumns.Ordinals[column.Name]
842 arg := column.convertArg(args[tableOrdinal])
843 uniqueKeyArgs = append(uniqueKeyArgs, arg)
844 }
845 return b.preparedStatement, uniqueKeyArgs, nil
846}
847
848// DMLInsertQueryBuilder can build INSERT queries for DML events.
849// It holds the prepared query statement so it doesn't need to be recreated every time.

Callers 5

TestBuildDMLDeleteQueryFunction · 0.95
WriteCheckpointMethod · 0.45
buildDMLEventQueryMethod · 0.45

Calls 4

ColumnsMethod · 0.80
convertArgMethod · 0.80
ErrorfMethod · 0.65
LenMethod · 0.45

Tested by 3

TestBuildDMLDeleteQueryFunction · 0.76