Reputation: 63
I'm getting a rpc error: code = 9 desc =
(no 'desc' in the error message) using the cloud.google.com/go/datastore
client package.
I have a struct:
type UserWidget struct {
ID string `datastore:"id"`
UserID string `datastore:"user"`
Widget string `datastore:"widget"`
Updated time.Time `datastore:"updated"`
}
And I'm attempting to execute a query against the populated datastore:
q := ds.NewQuery(userWidgetEntity)
q = q.Filter("user =", userID)
q = q.Filter("updated >", time.Now().Add(-1*duration))
The query executes fine if the updated filter isn't set, but fails with the above error if it is. I also see data in datastore and the updated field is listed as an index. A GQL update < DATETIME()
query executes correctly as well. I took a look at https://github.com/GoogleCloudPlatform/gcloud-golang/blob/master/datastore/query.go#L165 and it doesn't look like it handles synthetic literals. Maybe that's the issue?
Upvotes: 0
Views: 1012
Reputation: 2927
The filter on multiple properties requires an index to be defined. You should have an index.yaml file that includes:
indexes:
- kind: UserWidget
properties:
- name: user
- name: updated
That should be included in the error message; unfortunately there's a bug preventing that from happening.
Upvotes: 0