georgysavva / scany

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

Unsafe scan #120

Closed dvsnin closed 11 months ago

dvsnin commented 11 months ago

Hello! Could you help me, I really like your library and I actively use it. First of all, thanks for this!

How can I get behavior like in sqlx unsafe? so that I can do SELECT * FROM table and not worry

I really looked for a lot of information and I suspect that this is not possible (((

dvsnin commented 11 months ago

I use pgxscan with pgxpoll

georgysavva commented 11 months ago

Hi @dvasyanin! Thanks for opening this issue. You can use this scany API to do exactly that: https://pkg.go.dev/github.com/georgysavva/scany/v2@v2.0.0/dbscan#WithAllowUnknownColumns. With this option enabled, it's safe to scan data from the database with SELECT * FROM .... Feel free to reopen the issue if something doesn't work or if you still have questions.