func Delete(exec ExecFn, record interface{}) (stdsql.Result, error) { table, err := NewTable(record) if err != nil { return nil, err } pk := table.PrimaryKeyField() if pk == nil { return nil, errors.New(fmt.Sprintf("Table '%s' (%s) doesn't have a primary-key field", table.Name, table.SQLName)) } return exec(sql.DeleteQuery(table.SQLName, pk.SQL.Name), pk.Value) }
func TestDeleteQuery(t *testing.T) { assert.Equal(t, sql.DeleteQuery("yolo", "id"), "DELETE FROM yolo WHERE id=?") }