influxdata / influxdata/influxdb
models.Point::AddTag duplicates tags instead of replacing
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
`models.Point::AddTag` advertises that it replaces a tag value:
https://github.com/influxdata/influxdb/blob/d448b54e730f0d2f99540d89b0d8058f06db748f/models/points.go#L1675
Tags are never replaced and tags get duplicated on subsequent `models.Point::AddTag` calls like this example demonstrates:
```
package main
import (
"fmt"
"time"
"github.com/influxdata/influxdb/v2/models"
)
func main() {
point, err := models.NewPoint("measurement-name", models.Tags{
models.Tag{
Key: []byte("test-tag"),
Value: []byte("foo"),
},
}, models.Fields{"value": "0"}, time.Now().UTC())
if err != nil {
panic(err)
}
point.AddTag("test-tag", "bar")
fmt.Println(point.String())
}
```
Output:
```
measurement-name,test-tag=foo,test-tag=bar value="0" 1618153590745957567
```
Check correct `AddTag` implementation in influxdb-client-go:
https://github.com/influxdata/influxdb-client-go/blob/fa15edd8bd9549750d2f93b6ccb386434df63fbe/api/write/point.go#L58-L68
Contributor guide
Research direction
Start in models/points.go at the Point::AddTag implementation referenced by the issue, then compare its behavior with the linked influxdb-client-go implementation. Reproduce the example to confirm the duplicate tags, and finish when an existing tag key is replaced rather than duplicated on a subsequent AddTag call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100