More work to support nullable foreign keys

Adds nullable int/uint types
This commit is contained in:
Jamie Curnow
2023-05-30 22:26:44 +10:00
parent 88f3953f92
commit 4a57956093
14 changed files with 387 additions and 256 deletions

View File

@ -148,7 +148,7 @@ func getCertificateFromRequest(w http.ResponseWriter, r *http.Request) *certific
return nil
}
// getCertificateFromRequest has some reusable code for all endpoints that
// fillObjectFromBody has some reusable code for all endpoints that
// have a certificate id in the url. it will write errors to the output.
func fillObjectFromBody(w http.ResponseWriter, r *http.Request, validationSchema string, o interface{}) bool {
bodyBytes, _ := r.Context().Value(c.BodyCtxKey).([]byte)
@ -167,6 +167,7 @@ func fillObjectFromBody(w http.ResponseWriter, r *http.Request, validationSchema
err := json.Unmarshal(bodyBytes, o)
if err != nil {
logger.Debug("Unmarshal Error: %+v", err)
h.ResultErrorJSON(w, r, http.StatusBadRequest, h.ErrInvalidPayload.Error(), nil)
return false
}

View File

@ -87,7 +87,7 @@ func CreateHost() func(http.ResponseWriter, *http.Request) {
return
}
if newHost.UpstreamID > 0 {
if newHost.UpstreamID.Uint > 0 {
// nolint: errcheck, gosec
newHost.Expand([]string{"upstream"})
}