Select all fields in sql queries avoiding SELECT * FROM

This commit is contained in:
Luis Gómez 2020-11-08 15:25:57 -05:00
parent 832abda7a4
commit 72859db7a8

View File

@ -83,7 +83,7 @@ func BuildQuerySQL(db *gorm.DB) {
if smallerStruct {
stmt := gorm.Statement{DB: db}
// smaller struct
if err := stmt.Parse(db.Statement.Dest); err == nil && stmt.Schema.ModelType != db.Statement.Schema.ModelType {
if err := stmt.Parse(db.Statement.Dest); err == nil {
clauseSelect.Columns = make([]clause.Column, len(stmt.Schema.DBNames))
for idx, dbName := range stmt.Schema.DBNames {