Skip to content

omitEmpty, uncomparable type panic. #87

@nullboundary

Description

@nullboundary

Hi,

I have a set of complex nested struct data, that I am inserting into rethinkdb.

Here is a playground link of what my data looks like, and demonstrates it being unmarshalled by the go json package:
http://play.golang.org/p/NqlABINBey

When I try the same with gorethinkdb it works fine unless I add omitempty to the type "foodstructure". Then I get the following runtime panic. This could be simply my error, but since the JSON library seems to have no issues with it, I suspect its a bug in gorethink.

panic: "comparing uncomparable type main.foodStructure

/usr/local/go/src/pkg/runtime/panic.c:248 (0x16f76)
    panic: runtime·newstackcall(d->fn, (byte*)d->args, d->siz);
/Users/n/Documents/Development/gospace/src/github.com/dancannon/gorethink/encoding/encoder.go:22 (0x1b4338)
    com/dancannon/gorethink/encoding.func.001: panic(r)
/usr/local/go/src/pkg/runtime/panic.c:248 (0x16f76)
    panic: runtime·newstackcall(d->fn, (byte*)d->args, d->siz);
/usr/local/go/src/pkg/runtime/iface.c:613 (0xe1f3)
    ifaceeq1: runtime·panic(err);
/usr/local/go/src/pkg/runtime/iface.c:641 (0xe340)
    efaceeq_c: return ifaceeq1(e1.data, e2.data, e1.type);
/usr/local/go/src/pkg/runtime/iface.c:656 (0xe3e5)
    efaceeq: ret = runtime·efaceeq_c(e1, e2);
/Users/n/Documents/Development/gospace/src/github.com/dancannon/gorethink/encoding/encoder.go:161 (0x1b370b)
    com/dancannon/gorethink/encoding.isEmptyValue: return v.Interface() == reflect.Zero(v.Type()).Interface()
/Users/n/Documents/Development/gospace/src/github.com/dancannon/gorethink/encoding/encoder.go:68 (0x1b3381)
    com/dancannon/gorethink/encoding.encode: if !fv.IsValid() || f.omitEmpty && isEmptyValue(fv) {
/Users/n/Documents/Development/gospace/src/github.com/dancannon/gorethink/encoding/encoder.go:32 (0x1b1f11)
    com/dancannon/gorethink/encoding.Encode: val, err := encode(reflect.ValueOf(v))
/Users/n/Documents/Development/gospace/src/github.com/dancannon/gorethink/query_control.go:76 (0x8a57a)
    com/dancannon/gorethink.expr: data, err := encoding.Encode(val)
/Users/n/Documents/Development/gospace/src/github.com/dancannon/gorethink/query_control.go:19 (0x8a04d)
    com/dancannon/gorethink.Expr: return expr(value, 20)
/Users/n/Documents/Development/gospace/src/github.com/dancannon/gorethink/query_utils.go:67 (0x9452b)
    com/dancannon/gorethink.funcWrap: val := Expr(value)
/Users/n/Documents/Development/gospace/src/github.com/dancannon/gorethink/query_write.go:31 (0x94950)
    com/dancannon/gorethink.RqlTerm.Insert: return newRqlTermFromPrevVal(t, "Insert", p.Term_INSERT, []interface{}{funcWrap(arg)}, opts)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions