google app engine - AppEngine Datastore query with filter never returns results (Go) -


if don't use filter, results. if use filter (this record exists), don't results. might lack of index defined property, but, understand it, simple indices should automatically created in development server (and index.yaml file created , populated it). not happening.

query = datastore.newquery("useraccount").filter("email =", "test@example.com")  ua := useraccount{} t := query.run(ctx) ; ; {     if _, err = t.next(&ua); err == nil {         log.debugf(ctx, "current: %s", ua)     } else if err == datastore.done {         break     } else {         panic(err)     } } 

when development server terminates, states it's "saving search indexes":

info     2016-08-08 05:09:52,894 api_server.py:651] saving search indexes 

however, since "index.yaml" file doesn't appear, i'm assuming no indices needed created, means query must not've had desired effect?

what missing?

edit:

note record created , application stopped , started many times since. sincerely doubt eventual-consistency thing.

edit 2:

for purpose of testing, i've created following model following code. both exhibit same behavior original model , code.

definition:

type testentity struct {     email string } 

code:

log.debugf(ctx, "putting.")  email := "anothertest@a.b"  te := &testentity{         email: email, }  k := datastore.newkey(ctx, "testentity", "123", 0, nil) _, err = datastore.put(ctx, k, te) if err != nil {     panic(err) }  log.debugf(ctx, "waiting.") time.sleep(1 * time.second)  query := datastore.newquery("testentity")  var results []testentity _, err = query.getall(ctx, &results) log.debugf(ctx, "getall: %s", results)  log.debugf(ctx, "running query.")  query = datastore.newquery("testentity").filter("email =", email)  te = &testentity{} t := query.run(ctx) ; ; {     if _, err = t.next(te); err == nil {         log.debugf(ctx, "found: [%s]", te.email)     } else if err == datastore.done {         log.debugf(ctx, "done.")         break     } else {         panic(err)     } } 

results:

2016/08/09 02:11:36 debug: putting. 2016/08/09 02:11:36 debug: waiting. 2016/08/09 02:11:37 debug: getall: [{anothertest@a.b}] 2016/08/09 02:11:37 debug: running query. 2016/08/09 02:11:37 debug: done. 

screenshot of viewer:

screenshot of viewer

the property name in datastore "email" capital e, not "email".

it's case-sensitive, must queried capital e:

query = datastore.newquery("useraccount").filter("email =", "test@example.com") 

if want saved / retrieved small e, use tags mapping, e.g.:

type useraccount struct {     email string `datastore:"email"`     // other fields... } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -