georgysavva / scany

Library for scanning data from a database into Go structs and more
MIT License
1.27k stars 67 forks source link

Strict correspondence between structure fields and columns from SELECT #40

Closed egor-spk closed 3 years ago

egor-spk commented 3 years ago

The current implementation requires strict correspondence between the columns from the SELECT and the fields of the structure. Thus, additional columns cannot be used if they are not present in the target structure.

https://github.com/georgysavva/scany/blob/e037f9474e022887ad119d18abab10db523c0b56/dbscan/dbscan.go#L298-L303

Would you like to relax this rule? For example, this is useful when additional WHERE columns are needed, but they are not needed in the final structure.

georgysavva commented 3 years ago

Hello and thanks for this issue!

Can you explain better the use case for that change? Because if you have an additional column in WHERE you don't need to include it into SELECT and scany won't find out about them at all.

egor-spk commented 3 years ago

While writing the example, I refactored my large query and did without additional fields. Sorry to take your time :(