Convert: return nil when detector is empty

When PotentialNamespace is used detector is empty and
DetectorFromDatabaseModel() should return nil instead of empty object.
This commit is contained in:
Ales Raszka 2019-03-20 16:00:46 +01:00
parent f326b6f664
commit f2ce8325b9

View File

@ -153,6 +153,9 @@ func NamespacedFeatureFromDatabaseModel(feature database.AncestryFeature) *Featu
// DetectorFromDatabaseModel converts database detector to api detector. // DetectorFromDatabaseModel converts database detector to api detector.
func DetectorFromDatabaseModel(detector database.Detector) *Detector { func DetectorFromDatabaseModel(detector database.Detector) *Detector {
if !detector.Valid() {
return nil
}
return &Detector{ return &Detector{
Name: detector.Name, Name: detector.Name,
Version: detector.Version, Version: detector.Version,