Fix error that did not ignore fields with no ksql tags on QueryOne

The original attempt of fixing this problem was on commit:

e970a3546a
pull/10/head
Vinícius Garcia 2021-12-23 22:43:33 -03:00
parent d9f9d27266
commit 487e2aa6ac
2 changed files with 8 additions and 0 deletions

View File

@ -1130,6 +1130,11 @@ func buildSelectQueryForPlainStructs(
) string {
var fields []string
for i := 0; i < structType.NumField(); i++ {
structInfo := info.ByIndex(i)
if !structInfo.Valid {
continue
}
fields = append(fields, dialect.Escape(info.ByIndex(i).Name))
}

View File

@ -21,6 +21,9 @@ type User struct {
Age int `ksql:"age"`
Address Address `ksql:"address,json"`
// This attr has no ksql tag, thus, it should be ignored:
AttrThatShouldBeIgnored string
}
var UsersTable = NewTable("users")