diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-04-11 00:32:22 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-04-11 00:32:22 +0200 |
| commit | 04965ab5e7f2490bcb09b2b3242de4a46f2b1043 (patch) | |
| tree | c05a1f383495efe2040d33667e52bbca0dba6fd9 /internal/plan.go | |
| parent | 30984e9e686cc1dc2bede6784a2534371b02219d (diff) | |
| download | go-oblast-04965ab5e7f2490bcb09b2b3242de4a46f2b1043.tar.gz | |
reduce function body of Select()
Diffstat (limited to 'internal/plan.go')
| -rw-r--r-- | internal/plan.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/plan.go b/internal/plan.go index 8fc24d8..f738278 100644 --- a/internal/plan.go +++ b/internal/plan.go @@ -46,9 +46,16 @@ var ( // BuildPlan creates a new plan for the given struct type. func BuildPlan(t reflect.Type, dialect Dialect) (Plan, error) { + p, err := buildPlan(t, dialect) + if err != nil { + return Plan{}, fmt.Errorf("cannot use type %s.%s for queries: %w", t.PkgPath(), t.Name(), err) + } + return p, nil +} + +func buildPlan(t reflect.Type, dialect Dialect) (Plan, error) { if t.Kind() != reflect.Struct { - return Plan{}, fmt.Errorf("expected record type to be a struct, but got kind %s (full type: %s.%s)", - t.Kind(), t.PkgPath(), t.Name()) + return Plan{}, fmt.Errorf("expected struct type, but got kind %s", t.Kind().String()) } var p = Plan{ |
