Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7366](https://github.com/apache/trafficcontrol/pull/7366) *t3c* Removed timestamp from metadata file since it's changing every minute and causing excessive commits to git repo.

### Fixed
- [#7130](https://github.com/apache/trafficcontrol/issues/7130) *Traffic Ops* Fixes service_categories response to POST API.
- [#7340](https://github.com/apache/trafficcontrol/pull/7340) *Traffic Router* Fixed TR logging for the `cqhv` field when absent.
- [#5557](https://github.com/apache/trafficcontrol/issues/5557) *Traffic Portal* Moved `Fair Queueing Pacing Rate Bps` DS field to `Cache Configuration Settings` section.
- [#7252](https://github.com/apache/trafficcontrol/issues/7252) *Traffic Router* Fixed integer overflow for `czCount`, by resetting the count to max value when it overflows.
Expand Down
19 changes: 18 additions & 1 deletion traffic_ops/traffic_ops_golang/api/generic_crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,36 @@ func GenericCreateNameBasedID(val GenericCreator) (error, error, int) {
}
defer resultRows.Close()

var name string
lastUpdated := tc.TimeNoMod{}
rowsAffected := 0

for resultRows.Next() {
rowsAffected++
if err := resultRows.Scan(&lastUpdated); err != nil {
// Only when the type is of serviceCategory, &name is scanned and returned from the DB.
// Else return only &lastUpdated.
var err error
if val.GetType() == "serviceCategory" {
err = resultRows.Scan(&name, &lastUpdated)
} else {
err = resultRows.Scan(&lastUpdated)
}
if err != nil {
return nil, errors.New(val.GetType() + " create scanning: " + err.Error()), http.StatusInternalServerError
}
}

if rowsAffected == 0 {
return nil, errors.New(val.GetType() + " create: no " + val.GetType() + " was inserted, no row was returned"), http.StatusInternalServerError
} else if rowsAffected > 1 {
return nil, errors.New("too many rows returned from " + val.GetType() + " insert"), http.StatusInternalServerError
}

// Only when the type is of serviceCategory, setKeys to return name parameter.
if val.GetType() == "serviceCategory" {
val.SetKeys(map[string]interface{}{"name": name})
}

val.SetLastUpdated(lastUpdated)
return nil, nil, http.StatusOK
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (serviceCategory TOServiceCategory) Validate() (error, error) {
}

func (serviceCategory *TOServiceCategory) Create() (error, error, int) {
return api.GenericCreate(serviceCategory)
return api.GenericCreateNameBasedID(serviceCategory)
}

func (serviceCategory *TOServiceCategory) Read(h http.Header, useIMS bool) ([]interface{}, error, error, int, *time.Time) {
Expand Down