summaryrefslogtreecommitdiffstats
path: root/sqlr_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'sqlr_test.go')
-rw-r--r--sqlr_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/sqlr_test.go b/sqlr_test.go
index 4323f11..4625fde 100644
--- a/sqlr_test.go
+++ b/sqlr_test.go
@@ -54,6 +54,17 @@ func TestScan(t *testing.T) {
ColA int `sql:"col_a"`
ColB string `sql:"col_b"`
}{100, "test"},
+ }, {
+ desc: "embedded struct",
+ db: `
+ CREATE TABLE Tbl (Col);
+ INSERT INTO Tbl VALUES (100)`,
+ query: "SELECT Col FROM Tbl",
+ want: func() any {
+ type Inner struct{ Col int }
+ type outer struct{ Inner }
+ return &outer{Inner{100}}
+ }(),
}} {
t.Run(tc.desc, func(t *testing.T) {
db, err := sql.Open("sqlite3", ":memory:")
@@ -129,6 +140,13 @@ func TestScan_Errors(t *testing.T) {
out: new(struct {
Col int `sql:"-"`
}),
+ }, {
+ desc: "unexported field",
+ db: `
+ CREATE TABLE Tbl (col);
+ INSERT INTO Tbl VALUES (100)`,
+ query: "SELECT col FROM Tbl",
+ out: new(struct{ col int }),
}} {
t.Run(tc.desc, func(t *testing.T) {
db, err := sql.Open("sqlite3", ":memory:")