fix(models): models id change can not be save (#49)

This commit is contained in:
Fodesu
2026-02-14 23:40:47 +08:00
committed by GitHub
parent e6580d7837
commit 6f5ee013e6
3 changed files with 11 additions and 6 deletions
+1
View File
@@ -104,6 +104,7 @@ RETURNING *;
-- name: UpdateModelByModelID :one
UPDATE models
SET
model_id = sqlc.arg(new_model_id),
name = sqlc.arg(name),
llm_provider_id = sqlc.arg(llm_provider_id),
dimensions = sqlc.arg(dimensions),
+9 -6
View File
@@ -673,17 +673,19 @@ func (q *Queries) UpdateModel(ctx context.Context, arg UpdateModelParams) (Model
const updateModelByModelID = `-- name: UpdateModelByModelID :one
UPDATE models
SET
name = $1,
llm_provider_id = $2,
dimensions = $3,
is_multimodal = $4,
type = $5,
model_id = $1,
name = $2,
llm_provider_id = $3,
dimensions = $4,
is_multimodal = $5,
type = $6,
updated_at = now()
WHERE model_id = $6
WHERE model_id = $7
RETURNING id, model_id, name, llm_provider_id, dimensions, is_multimodal, type, created_at, updated_at
`
type UpdateModelByModelIDParams struct {
NewModelID string `json:"new_model_id"`
Name pgtype.Text `json:"name"`
LlmProviderID pgtype.UUID `json:"llm_provider_id"`
Dimensions pgtype.Int4 `json:"dimensions"`
@@ -694,6 +696,7 @@ type UpdateModelByModelIDParams struct {
func (q *Queries) UpdateModelByModelID(ctx context.Context, arg UpdateModelByModelIDParams) (Model, error) {
row := q.db.QueryRow(ctx, updateModelByModelID,
arg.NewModelID,
arg.Name,
arg.LlmProviderID,
arg.Dimensions,
+1
View File
@@ -235,6 +235,7 @@ func (s *Service) UpdateByModelID(ctx context.Context, modelID string, req Updat
params := sqlc.UpdateModelByModelIDParams{
ModelID: modelID,
NewModelID: model.ModelID,
IsMultimodal: model.IsMultimodal,
Type: string(model.Type),
}