Lock the provider row until the model-config write completes. The transaction alone does not stop a concurrent soft-delete or disable between validation and writing the model config reference.
(ctx context.Context, id uuid.UUID)
| 465 | // transaction alone does not stop a concurrent soft-delete or disable |
| 466 | // between validation and writing the model config reference. |
| 467 | func (q *sqlQuerier) GetAIProviderByIDForReferenceLock(ctx context.Context, id uuid.UUID) (AIProvider, error) { |
| 468 | row := q.db.QueryRowContext(ctx, getAIProviderByIDForReferenceLock, id) |
| 469 | var i AIProvider |
| 470 | err := row.Scan( |
| 471 | &i.ID, |
| 472 | &i.Type, |
| 473 | &i.Name, |
| 474 | &i.DisplayName, |
| 475 | &i.Enabled, |
| 476 | &i.Deleted, |
| 477 | &i.BaseUrl, |
| 478 | &i.Settings, |
| 479 | &i.SettingsKeyID, |
| 480 | &i.CreatedAt, |
| 481 | &i.UpdatedAt, |
| 482 | ) |
| 483 | return i, err |
| 484 | } |
| 485 | |
| 486 | const getAIProviderByName = `-- name: GetAIProviderByName :one |
| 487 | SELECT |
nothing calls this directly
no test coverage detected