Blair Connolly
Blair Connolly

Reputation: 604

Getting weird error on datastore.Query.Run(c).Next(x)

I have not run into this particular error before, and when I Google it I can't find anything at all out there that even mentions it. I am using Go language, performing a standard datastore query like I have many times before using an iterator, and I get this error: "proto: required fields not set in datastore.QueryResult". See my code below, any ideas?

k, err := datastore.NewQuery("QBConnection").
    Ancestor(datastore.NewKey(c, "Company", "", x.CompanyID, nil)).
    Limit(1).
    Run(c).
    Next(x)
if err != nil {
    if _, ok := err.(*datastore.ErrFieldMismatch); ok { err = nil } //ignore it if we can't load some fields
    if err == datastore.Done { err = nil } //If we don't find it in datastore, then just return nil
    if err != nil {return err}
}

Upvotes: 1

Views: 382

Answers (1)

Blair Connolly
Blair Connolly

Reputation: 604

I figure it out for my case, at least. I'm still unsure exactly what the error message is supposed to mean, and I got a different error when I ran this in the live environment (which led to my answer). On the live site it told me "ancestor missing id/name"... long story short, my x.CompanyID variable was not set properly before running the query. Not sure why the error messages were so different on dev/live, and sure would have helped to get the missing id/name error on my dev server... but oh well, problem solved.

Upvotes: 3

Related Questions