Fix #52: query matcher doesn't handle arrays tables

Also improve coverage of query matcher.
This commit is contained in:
Thomas Pelletier
2016-03-16 09:56:04 -07:00
parent fe63e9f76d
commit d6a90e60ed
4 changed files with 99 additions and 2 deletions
+8 -1
View File
@@ -67,7 +67,14 @@ func newMatchKeyFn(name string) *matchKeyFn {
}
func (f *matchKeyFn) call(node interface{}, ctx *queryContext) {
if tree, ok := node.(*TomlTree); ok {
if array, ok := node.([]*TomlTree); ok {
for _, tree := range array {
item := tree.values[f.Name]
if item != nil {
f.next.call(item, ctx)
}
}
} else if tree, ok := node.(*TomlTree); ok {
item := tree.values[f.Name]
if item != nil {
f.next.call(item, ctx)