Skip to content
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

fix(dbrpv2): reflect match count correctly #18211

Merged
merged 1 commit into from
May 26, 2020
Merged

Conversation

gavincabbage
Copy link
Contributor

@gavincabbage gavincabbage commented May 25, 2020

This PR fixes a bug in the V2 DBRP Mapping Service where the number of matching mappings was returned incorrectly because the length of the match list was calculated before it was populated.

An illustration of the bug on the Go playground:

func main() {

	n, a := func() (int, []string) {
		var b []string
		return len(b), func() []string {
			for i := 0; i < 3; i++ {
				b = append(b, fmt.Sprintf("%d", i))
			}
			return b
		}()
	}()

	fmt.Printf("n: %d, a: %v\n", n, a)
}
n: 0, a: [0 1 2]

Tests are also updated and have been confirmed to fail without the fix in place.

Copy link
Contributor

@stuartcarnie stuartcarnie left a comment

Choose a reason for hiding this comment

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

Awesome – great find and thanks for fixing!

@stuartcarnie stuartcarnie added the area/influxql Issues related to InfluxQL query language label May 26, 2020
@gavincabbage gavincabbage merged commit 715e2fb into master May 26, 2020
@gavincabbage gavincabbage deleted the fix/dbrpv2-count branch May 26, 2020 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/influxql Issues related to InfluxQL query language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants