Update host (#278)

* Add IsNotNullError function to db package

* Let the database handle default values not gorm

* Implement UpdateHost

* Remove unnecessary clone
This commit is contained in:
Michael Gaffney authored and GitHub committed 2020-08-18 16:50:26 -04:00
1 parent e18cdc52b3
commit 041e1f9fd3
6 files changed
+647 -4

No files matched your search

+17
View File
@@ -75,3 +75,20 @@ func IsCheckConstraintError(err error) bool {
return false
}
// IsNotNullError returns a boolean indicating whether the error is known
// to report a not-null constraint violation.
func IsNotNullError(err error) bool {
if err == nil {
return false
}
var pqError *pq.Error
if errors.As(err, &pqError) {
if pqError.Code.Name() == "not_null_violation" {
return true
}
}
return false
}