Skip to content

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

Merged
merged 4 commits into from
May 23, 2023
Merged

add support for scan op #3

merged 4 commits into from
May 23, 2023

Conversation

jycor
Copy link

@jycor jycor commented May 23, 2023

The asterisk operator (*), is compiled into the "scan" operation, which we are missing a case for.
Fix for: dolthub/dolt#6006

@jycor jycor requested a review from reltuk May 23, 2023 21:21
Copy link

@timsehn timsehn left a 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")
Copy link

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.

Copy link

@reltuk reltuk left a 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)
Copy link

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
Comment on lines 571 to 573
for _, kv := range reflect.ValueOf(obj).MapKeys() {
res = append(res, reflect.ValueOf(obj).MapIndex(kv).Interface())
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly better as:

Suggested change
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())
}

?

@jycor jycor merged commit 77b8157 into master May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants