Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Empty Array when no values returned similar to redis-cli #120

Merged
merged 1 commit into from
Jan 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/redis-custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
"github.com/mediocregopher/radix/v3"
)

// EmptyArray for (empty array)
const EmptyArray = "(empty array)"

/**
* Execute Query
* Can PANIC if command is wrong
Expand Down Expand Up @@ -72,7 +75,7 @@ func (ds *redisDatasource) parseInterfaceValue(value []interface{}, response bac

// If no values
if len(parsedValues) == 0 {
parsedValues = append(parsedValues, "(empty array)")
parsedValues = append(parsedValues, EmptyArray)
}

values = append(values, parsedValues...)
Expand Down Expand Up @@ -140,7 +143,11 @@ func (ds *redisDatasource) queryCustomCommand(qm queryModel, client ClientInterf
var values []string

// Parse values
values, response = ds.parseInterfaceValue(result, response)
if len(values) == 0 {
values = append(values, EmptyArray)
} else {
values, response = ds.parseInterfaceValue(result, response)
}

// Error when parsing intarface
if response.Error != nil {
Expand Down