Fix database/query issue

This commit is contained in:
Daniel 2019-02-14 13:45:38 +01:00
parent 4bfff91279
commit 15ea65a61d
2 changed files with 4 additions and 3 deletions

View file

@ -125,8 +125,8 @@ func (q *Query) MatchesAccessor(acc accessor.Accessor) bool {
// Matches checks whether the query matches the supplied database record.
func (q *Query) Matches(r record.Record) bool {
if q.MatchesKey(r.DatabaseKey()) {
return true
if !q.MatchesKey(r.DatabaseKey()) {
return false
}
return q.MatchesRecord(r)
}

View file

@ -4,6 +4,7 @@ import (
"testing"
"github.com/Safing/portbase/database/record"
"github.com/Safing/portbase/formats/dsd"
)
var (
@ -65,7 +66,7 @@ func TestQuery(t *testing.T) {
// if !gjson.Valid(testJSON) {
// t.Fatal("test json is invalid")
// }
r, err := record.NewWrapper("", nil, append([]byte("J"), []byte(testJSON)...))
r, err := record.NewWrapper("", nil, dsd.JSON, []byte(testJSON))
if err != nil {
t.Fatal(err)
}