(ctx context.Context, params *riverdriver.JobDeleteManyParams)
| 409 | } |
| 410 | |
| 411 | func (e *Executor) JobDeleteMany(ctx context.Context, params *riverdriver.JobDeleteManyParams) ([]*rivertype.JobRow, error) { |
| 412 | ctx = sqlctemplate.WithReplacements(ctx, map[string]sqlctemplate.Replacement{ |
| 413 | "order_by_clause": {Value: params.OrderByClause}, |
| 414 | "where_clause": {Value: params.WhereClause}, |
| 415 | }, params.NamedArgs) |
| 416 | |
| 417 | jobs, err := dbsqlc.New().JobDeleteMany(schemaTemplateParam(ctx, params.Schema), e.dbtx, int64(params.Max)) |
| 418 | if err != nil { |
| 419 | return nil, interpretError(err) |
| 420 | } |
| 421 | // This is unfortunate. SQLite doesn't support `DELETE` in CTEs, so there's |
| 422 | // no way to get reliable ordering back. It has a non-standard `ORDER BY` |
| 423 | // statement in `DELETE`, but this is only used to determine what fits |
| 424 | // inside `LIMIT`, and again not guaranteed to be the order returned by |
| 425 | // `RETURNING`. Here, order post-operation before returning from driver. |
| 426 | slices.SortFunc(jobs, func(j1, j2 *dbsqlc.RiverJob) int { return int(j1.ID - j2.ID) }) |
| 427 | return sliceutil.MapError(jobs, jobRowFromInternal) |
| 428 | } |
| 429 | |
| 430 | // This really sucks, but this SQL fragment's been extracted to a string because |
| 431 | // sqlc is buggy and can't parse it. |
nothing calls this directly
no test coverage detected