From 487e2aa6ac8f7b3f9723b529c191c6097ef3a189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Garcia?= Date: Thu, 23 Dec 2021 22:43:33 -0300 Subject: [PATCH] Fix error that did not ignore fields with no ksql tags on QueryOne The original attempt of fixing this problem was on commit: e970a3546a0635989d27e68d9741118d99d11490 --- ksql.go | 5 +++++ ksql_test.go | 3 +++ 2 files changed, 8 insertions(+) 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")