structable icon indicating copy to clipboard operation
structable copied to clipboard

ListWhere() silently fails and returns empty objects

Open sgabe opened this issue 3 years ago • 1 comments

It seems that ListWhere() is unable to convert a []Recorder back to its real type and returns an empty base object. Further investigation showed that there is a contradiction within the function on how to handle keys.

The below snippet shows that the includeKeys parameter of Column() is false hence columns that are marked as keys will be omitted from the returned list.

https://github.com/Masterminds/structable/blob/a1a302ef78ec3d85606dcf104a9a168542004036/structable.go#L309

However, later the withKeys parameter of FieldReferences() is true hence fields marked as keys will be included in the returned list.

https://github.com/Masterminds/structable/blob/a1a302ef78ec3d85606dcf104a9a168542004036/structable.go#L340

This will currently result in a mismatch between the number of columns and throw an ERROR: sql: expected 19 destination arguments in Scan, not 20 message. Unfortunately, errors returned by rows.Scan(dest...) are ignored hence the function will silently fail and return an empty base object.

sgabe avatar Aug 16 '20 11:08 sgabe

is this repo maintained? why isn't it merged?

AlmogBaku avatar Nov 14 '21 21:11 AlmogBaku