diff --git a/database/pgsql/keyvalue.go b/database/pgsql/keyvalue.go index 6cdaf31e..ce16e894 100644 --- a/database/pgsql/keyvalue.go +++ b/database/pgsql/keyvalue.go @@ -14,7 +14,11 @@ package pgsql -import cerrors "github.com/coreos/clair/utils/errors" +import ( + "database/sql" + + cerrors "github.com/coreos/clair/utils/errors" +) // InsertKeyValue stores (or updates) a single key / value tuple. func (pgSQL *pgSQL) InsertKeyValue(key, value string) (err error) { @@ -62,6 +66,10 @@ func (pgSQL *pgSQL) InsertKeyValue(key, value string) (err error) { func (pgSQL *pgSQL) GetKeyValue(key string) (string, error) { var value string err := pgSQL.QueryRow(getQuery("s_keyvalue"), key).Scan(&value) + + if err == sql.ErrNoRows { + return "", nil + } if err != nil { return "", handleError("s_keyvalue", err) } diff --git a/database/pgsql/notification.go b/database/pgsql/notification.go index 28dae70c..847e8f97 100644 --- a/database/pgsql/notification.go +++ b/database/pgsql/notification.go @@ -14,7 +14,7 @@ import ( // do it in tx so we won't insert/update a vuln without notification and vice-versa. func (pgSQL *pgSQL) insertNotification(tx *sql.Tx, notification interface{}) error { - kind := reflect.Indirect(reflect.ValueOf(notification)).Type() + kind := reflect.Indirect(reflect.ValueOf(notification)).Type().String() data, err := json.Marshal(notification) if err != nil { tx.Rollback()