Add query and chart support with multiple fixes to ORM package

This commit is contained in:
Patrick Pacher 2022-05-03 16:11:12 +02:00
parent 0d2ec9df75
commit 25aceaf103
No known key found for this signature in database
GPG key ID: E8CD2DA160925A6D
11 changed files with 535 additions and 117 deletions

View file

@ -20,6 +20,7 @@ type (
NamedArgs map[string]interface{}
Result interface{}
DecodeConfig DecodeConfig
Schema TableSchema
}
)
@ -56,6 +57,12 @@ func WithNamedArgs(args map[string]interface{}) QueryOption {
}
}
func WithSchema(tbl TableSchema) QueryOption {
return func(opts *queryOpts) {
opts.Schema = tbl
}
}
// WithResult sets the result receiver. result is expected to
// be a pointer to a slice of struct or map types.
//
@ -136,7 +143,7 @@ func RunQuery(ctx context.Context, conn *sqlite.Conn, sql string, modifiers ...Q
currentField = reflect.New(valElemType)
if err := DecodeStmt(ctx, stmt, currentField.Interface(), args.DecodeConfig); err != nil {
if err := DecodeStmt(ctx, &args.Schema, stmt, currentField.Interface(), args.DecodeConfig); err != nil {
return err
}