From 13d3e853173a2034d1551753ea5f5ecaf6139095 Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Sun, 9 Jan 2022 18:30:35 +0800 Subject: [PATCH] update --- attribute/attribute.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/attribute/attribute.go b/attribute/attribute.go index afbe9d2..368c856 100644 --- a/attribute/attribute.go +++ b/attribute/attribute.go @@ -65,11 +65,12 @@ func RestoreDefault(key string) error { } func Get(key string) string { - var value string - store.DB. - Raw(`select "value" from "attributes" where "key" = ?`, key). - Scan(&value) - return value + a := &Attribute{} + store.DB.Select("value", "default").First(a, "key = ?", key) + if a.Value == "" { + return a.Default + } + return a.Value } func Set(key, value string) error {