pgtype icon indicating copy to clipboard operation
pgtype copied to clipboard

Misleading error message

Open duohedron opened this issue 5 years ago • 5 comments
trafficstars

There are misleading error messages in Set(src interface{}) in polygon.go, circle.go etc... The error message cannot convert %v to T implies that other types can be converted. It should say that the function is not yet implemented.

duohedron avatar Sep 15 '20 07:09 duohedron

I'm not sure about that. Saying it is not yet implemented implies that it could be implemented. But there are no standard Go types that could be mapped to those geometry types. Saying that type X cannot be converted to Y is correct... it's just it is true for all type X.

I suppose a better message might clarify that no types are convertible...

jackc avatar Sep 15 '20 22:09 jackc

I think the string representation can be mapped to geometry types, or for example [][]float64 to polygon. I can implement it and create a pull request.

duohedron avatar Sep 18 '20 10:09 duohedron

I'm open to supporting some type being settable. Though I wouldn't do a [][]float64. The extra slice per point would be inefficient. I would use []pgtype.Vec2 instead. ... In fact, now I'm wondering why I didn't have Set() handle that originally... 🤷

jackc avatar Sep 18 '20 14:09 jackc

I created a pull request for Polygon.Set(src interface{}) #63 If you find it adequate I can implement Set() for the other geometric types as well.

duohedron avatar Oct 06 '20 07:10 duohedron

It's okay with the one change I mentioned. If you want to do something similar for the other geometric types that would be fine.

jackc avatar Oct 08 '20 12:10 jackc