-
Notifications
You must be signed in to change notification settings - Fork 1
add support for scan op #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad error message too
jsonpath.go
Outdated
obj, err = get_scan(obj) | ||
if err != nil { | ||
return nil, err | ||
} | ||
default: | ||
return nil, fmt.Errorf("expression don't support in filter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error sux. Fix that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. A couple suggestions.
jsonpath_test.go
Outdated
"key": 1, | ||
} | ||
res, err := get_scan(obj) | ||
fmt.Println(err, res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file seems to use both fmt.Println
and t.Logf
in the tests, but t.Logf
is preferable, so let's use that here.
jsonpath.go
Outdated
for _, kv := range reflect.ValueOf(obj).MapKeys() { | ||
res = append(res, reflect.ValueOf(obj).MapIndex(kv).Interface()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly better as:
for _, kv := range reflect.ValueOf(obj).MapKeys() { | |
res = append(res, reflect.ValueOf(obj).MapIndex(kv).Interface()) | |
} | |
iter := reflect.ValueOf(obj).MapRange() | |
for iter.Next() { | |
res = append(res, iter.Value().Interface()) | |
} |
?
The asterisk operator (
*
), is compiled into the"scan"
operation, which we are missing a case for.Fix for: dolthub/dolt#6006