radix icon indicating copy to clipboard operation
radix copied to clipboard

Flatten with empty slice in struct yields wrong number of arguments

Open dokterbob opened this issue 2 years ago • 0 comments

A struct of the form:

struct {
	Other  string
	Nested []string
}

with with Nested left to it's empty value, generates an invalid number of arguments for HMSET, leading to the error: unmarshaling message off Conn: ERR wrong number of arguments for 'hmset' command

Suggested solutions:

  1. Defaulting for Nested to an empty string "" for empty values, consistent with normal empty string values, explicitly emptying the value.
  2. Adding an omitempty option, preventing this value from being (over)written with HMSET.

dokterbob avatar Oct 08 '22 15:10 dokterbob