db can query 1 level nested dotnotation

This commit is contained in:
Bel LaPointe
2025-04-27 11:04:17 -06:00
parent a199e34730
commit b85df7bd31
2 changed files with 53 additions and 6 deletions

View File

@@ -46,4 +46,15 @@ func TestDB(t *testing.T) {
} else if gots[1].K != "b" {
t.Errorf("expected [1]='b' but got %q", gots[1].K)
}
type NestedResult struct {
Nest struct {
K string `json:"k"`
}
}
if got, err := db.QueryOne[NestedResult](ctx, `SELECT k AS "Nest.k" FROM test WHERE k='a'`); err != nil {
t.Errorf("failed nested query one: %v", err)
} else if got.Nest.K != "a" {
t.Errorf("bad nested query one: %+v", got)
}
}