From e4c521d9b3c168db92cecfb6c4a5df1e2f505d6c Mon Sep 17 00:00:00 2001 From: Theresa Gresch Date: Fri, 15 May 2020 13:16:03 +0200 Subject: [PATCH] Backend: Update FindPlaceByLabel function --- internal/entity/place.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/entity/place.go b/internal/entity/place.go index 5677e911b..6ec3c4084 100644 --- a/internal/entity/place.go +++ b/internal/entity/place.go @@ -51,7 +51,12 @@ func (m *Place) AfterCreate(scope *gorm.Scope) error { func FindPlaceByLabel(id string, label string) *Place { place := &Place{} - if err := Db().First(place, "id = ? OR loc_label = ?", id, label).Error; err != nil { + if label == "" { + if err := Db().First(place, "id = ?", id).Error; err != nil { + log.Debugf("place: %s for id %s", err.Error(), id) + return nil + } + } else if err := Db().First(place, "id = ? OR loc_label = ?", id, label).Error; err != nil { log.Debugf("place: %s for id %s or label %s", err.Error(), id, txt.Quote(label)) return nil }