谷歌应用引擎 – ByteString 查询失败

huangapple go评论91阅读模式
英文:

Google App Engine - ByteString query fails

问题

我正在开发一个Go应用程序,其中有一个实体(Entity),它具有一个属性(Property),用于保存一个标识令牌,该令牌是一串随机的字节。我将这个属性存储为ByteString,在我的开发环境中,我可以使用以下形式的过滤器查询该属性:

// token是[]byte类型
idTok := datastore.ByteString(token)
q := ds.NewQuery("Entity").Filter("IDToken =", idTok)

var entities []Entity
keys, err := q.GetAll(c, &entities)

但不幸的是,当部署为GAE模块时,这个查询返回错误:datastore: bad query filter value type: unsupported datastore value type: datastore.ByteString,这让我感到困惑,因为我认为ByteString类型的目的是能够在500字节以下的二进制数据上建立索引。

我首先根据这个stackoverflow问题的第二个答案切换到使用ByteString类型:https://stackoverflow.com/questions/25829202/golang-appengine-datastore-filter-query-with-byte-comparison

英文:

I am working on a Go application in which I have an Entity with a Property that holds an identifying token which is a random string of bytes. I am storing this property as a ByteString, and in my development environment I have been able to query for this property using a filter of the form:

// token is a []byte
idTok := datastore.ByteString(token)
q := ds.NewQuery("Entity").Filter("IDToken =", idTok)

var entities []Entity
keys, err := q.GetAll(c, &entities)

But unfortunately, when deployed as a module to GAE, this query returns the error: datastore: bad query filter value type: unsupported datastore value type: datastore.ByteString, which is confusing since I thought the purpose of the ByteString type is to be able to index shorter amounts of binary data under 500 bytes.

I first switched over to using the ByteString type based on the second answer to this SO question: https://stackoverflow.com/questions/25829202/golang-appengine-datastore-filter-query-with-byte-comparison

答案1

得分: 0

这个问题大约一周后自行解决了。由于它只出现在模块环境中,我猜测他们的某段代码可能没有更新以支持ByteString类型,现在已经更新了。现在运行得很好!

英文:

This issue resolved itself about a week later. Since it only appeared in the module environment, I am guessing that some piece of their code had not been updated to support the ByteString type, and now is. Works great now!

huangapple
  • 本文由 发表于 2015年2月24日 05:03:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/28683393.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定