Freebase的“键光标是保留字" [英] Freebase "Key cursor is a reserved word"

查看:93
本文介绍了Freebase的“键光标是保留字"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照Freebase 有关信封参数的文档,正在运行

{
  "cursor":true,
  "query":[{
    "type":"/music/album",
    "artist":"The Police",
    "name":null,
    "limit":10
  }]
}​

作为 @Domenic注释. /p>

怎么了?


编辑1

因此的损坏版本是有意义的,因为读取参数类型表query"cursor"都作为type: string,并且如果将query"cursor"都用引号引起来,则query会出错.

但是,即使将"cursor"用引号引起来也仍然无效:每次查询都会得到相同的数据.

解决方案

看起来这可能是查询编辑器过于智能并无法为我们解决问题的另一种情况.如果将上面的查询复制并粘贴到查询编辑器中,然后按运行",将按照您的报告显示此错误:

{
  "code":          "/api/status/error",
      "messages": [{
    "code":    "/api/status/error/mql/type",
    "info": {
      "expected_type": "/type/object",
      "property":      "cursor"
    },
    "message": "Key cursor is a reserved word",
    "path":    "",
    "query": {
      "cursor":       true,
      "error_inside": ".",
      "query": [{
        "artist": "The Police",
        "limit":  10,
        "name":   null,
        "type":   "/music/album"
      }]
    }
  }],
  "status":        "200 OK",
  "transaction_id": "cache;cache03.p01.sjc1:8101;2011-11-04T17:42:13Z;0057"
}

但是,如果您单击该查询的永久链接,它将更改为该查询,并自动将cursor属性设置为true.

[{
  "type":   "/music/album",
  "artist": "The Police",
  "name":   null,
  "limit":  10
}]​

发生这种情况是因为MQL读取服务希望查询嵌套在查询信封,但查询编辑器只接受您提供的查询,并自动将其包装在适合您的查询信封中.

在新版本的 MQL读取服务中,我们已经取消了查询信封,现在 cursor 只是HTTP GET请求上的一个参数.

Following the Freebase docs on Envelope Parameters, running

{
  "cursor":true,
  "query":[{
    "type":"/music/album",
    "artist":"The Police",
    "name":null,
    "limit":10
  }]
}​

results in error "Key cursor is a reserved word" as @Domenic notes.

What's going wrong?


Edit 1

So this query without a cursor works but this one doesn't because cursor was a variable name not a string enclosed in quotes.

As a user it makes sense to type the broken version of "cursor" because the read parameter type table has both query and "cursor" as type: string, and query errors out if your enclose it in quotes as "query"

However, even enclosing "cursor" in quotes still doesn't work: it results in the same data for every query.

解决方案

It looks like this may be another case of the query editor being too smart and fixing things for us. If you copy and paste the query above into the query editor and press Run you will get this error as you reported:

{
  "code":          "/api/status/error",
      "messages": [{
    "code":    "/api/status/error/mql/type",
    "info": {
      "expected_type": "/type/object",
      "property":      "cursor"
    },
    "message": "Key cursor is a reserved word",
    "path":    "",
    "query": {
      "cursor":       true,
      "error_inside": ".",
      "query": [{
        "artist": "The Police",
        "limit":  10,
        "name":   null,
        "type":   "/music/album"
      }]
    }
  }],
  "status":        "200 OK",
  "transaction_id": "cache;cache03.p01.sjc1:8101;2011-11-04T17:42:13Z;0057"
}

But then if you click on the permalink to that query it changes it to this query and automatically sets the cursor property to true.

[{
  "type":   "/music/album",
  "artist": "The Police",
  "name":   null,
  "limit":  10
}]​

This happens because the MQL read service expects a query to be nested inside a query envelope but the query editor just takes the query you give it and automatically wraps it in an appropriate query envelope for you.

In the new version of the MQL read service, we've done away with the query envelope and now cursor is just a parameter on the HTTP GET request.

这篇关于Freebase的“键光标是保留字"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆