diff --git a/ksql.go b/ksql.go index 6658107..5794ae1 100644 --- a/ksql.go +++ b/ksql.go @@ -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)) } diff --git a/ksql_test.go b/ksql_test.go index 495b56d..047ae98 100644 --- a/ksql_test.go +++ b/ksql_test.go @@ -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")