georgysavva / scany

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

Does scany support "SELECT * <...>" queries? #79

Closed inliquid closed 2 years ago

inliquid commented 2 years ago

Documentation says the following:

In terms of scanning and mapping abilities, scany provides all features of sqlx

However I can't find any example of using scany with "select *" queries like in case of sqlx:

    // Query the database, storing results in a []Person (wrapped in []interface{})
    people := []Person{}
    db.Select(&people, "SELECT * FROM person ORDER BY first_name ASC")
georgysavva commented 2 years ago

Hello! You can use "SELECT *" with scany, there so no distinction on scany side. It's the same as you would list all columns manually in the SELECT statement. It's true as long as there a corresponding struct field for all columns in that table.

inliquid commented 2 years ago

Thank you!