InfluxCommunity / influxdb3-go

The go package that provides a simple and convenient way to interact with InfluxDB 3.
https://pkg.go.dev/github.com/InfluxCommunity/influxdb3-go
MIT License
21 stars 11 forks source link

QueryIterator: name of Method AsPoints can be misleading #60

Open karel-rehor opened 5 months ago

karel-rehor commented 5 months ago

Use Case

The Method on QueryIterator named AsPoints returns a pointer to an object of type PointValues. There is also the type Point.

Intuitively a developer could on first view expect a method named AsPoints to return an object of type or pointer to an object of type Point or a container holding objects of this type. When quickly coding Intellij IDE (And I imagine other IDEs as well) offers the Method AsPoints. Inattention to the actual return value can lead to this assumption. There are situations in which this misunderstood usage can compile, but at runtime leads to an NPE being thrown.

Expected behavior

Expect that a method returning a pointer or object of type PointValues to have a more intuitive name, when the return value can be confused with another type.

e.g.

  1. func (i *QueryIterator) AsPointValues() *PointValues{...}
  2. func (i *QueryIterator) AsValues() *PointValues{...}

Actual behavior

See Use Case section

Additional info

Changing the name of this method could of course break existing implementations. Adding this request for future discussion or review.