fix(storage,document,sqlite): fix nil pointer exception in query options

This commit is contained in:
wpetit 2023-03-01 13:06:32 +01:00
parent 8789b85d92
commit 8680e139e7
2 changed files with 9 additions and 4 deletions

View File

@ -102,7 +102,7 @@ func (m *Module) query(call goja.FunctionCall, rt *goja.Runtime) goja.Value {
} }
if queryOptions.Offset != nil { if queryOptions.Offset != nil {
queryOptionsFuncs = append(queryOptionsFuncs, storage.WithOffset(*queryOptions.Limit)) queryOptionsFuncs = append(queryOptionsFuncs, storage.WithOffset(*queryOptions.Offset))
} }
if queryOptions.OrderDirection != nil { if queryOptions.OrderDirection != nil {

View File

@ -127,7 +127,12 @@ func (s *DocumentStore) Query(ctx context.Context, collection string, filter *fi
args = append([]interface{}{collection}, args...) args = append([]interface{}{collection}, args...)
if opts.OrderBy != nil { if opts.OrderBy != nil {
query, args = withOrderByClause(query, args, *opts.OrderBy, *opts.OrderDirection) direction := storage.OrderDirectionAsc
if opts.OrderDirection != nil {
direction = *opts.OrderDirection
}
query, args = withOrderByClause(query, args, *opts.OrderBy, direction)
} }
if opts.Offset != nil || opts.Limit != nil { if opts.Offset != nil || opts.Limit != nil {