Google app engine GQL语法条件
我有一个简单的问题: 在GQL中 什么是Google app engine GQL语法条件,google-app-engine,gql,Google App Engine,Gql,我有一个简单的问题: 在GQL中 什么是:1 根据语法,应该有:= 谢谢。您发布的语法链接上的GQL语法如下: SELECT [* | __key__] FROM <kind> [WHERE <condition> [AND <condition> ...]] [ORDER BY <property> [ASC | DESC] [, <property> [ASC | DESC] ...]] [LIMIT [<offs
:1
根据语法,应该有:=
谢谢。您发布的语法链接上的GQL语法如下:
SELECT [* | __key__] FROM <kind>
[WHERE <condition> [AND <condition> ...]]
[ORDER BY <property> [ASC | DESC] [, <property> [ASC | DESC] ...]]
[LIMIT [<offset>,]<count>]
[OFFSET <offset>]
<condition> := <property> {< | <= | > | >= | = | != } <value>
<condition> := <property> IN <list>
<condition> := ANCESTOR IS <entity or key>
然后,我们可以替换第一个条件表达式,即:
<condition> := <property> {< | <= | > | >= | = | != } <value>
根据,1表示该值将绑定到GqlQuery()
(查询后)的第一个参数。因此,在本例中,值为users.get\u current\u user()
更新:
我认为这两种方法都不行,因为它们都缺少一个双引号来结束查询字符串。但是,以下两项都应起作用:
query = db.GqlQuery(
"SELECT * FROM Rep WHERE author = :1",
users.get_current_user())
user = users.get_current_user()
query = db.GqlQuery(
"SELECT * FROM Rep WHERE author = :1",
user)
拥有查询对象后,可以对其调用
fetch()
,以获取列表形式的项目。或者,您也可以直接迭代查询。您发布的语法链接上的GQL语法如下:
SELECT [* | __key__] FROM <kind>
[WHERE <condition> [AND <condition> ...]]
[ORDER BY <property> [ASC | DESC] [, <property> [ASC | DESC] ...]]
[LIMIT [<offset>,]<count>]
[OFFSET <offset>]
<condition> := <property> {< | <= | > | >= | = | != } <value>
<condition> := <property> IN <list>
<condition> := ANCESTOR IS <entity or key>
然后,我们可以替换第一个条件表达式,即:
<condition> := <property> {< | <= | > | >= | = | != } <value>
根据,1表示该值将绑定到GqlQuery()
(查询后)的第一个参数。因此,在本例中,值为users.get\u current\u user()
更新:
我认为这两种方法都不行,因为它们都缺少一个双引号来结束查询字符串。但是,以下两项都应起作用:
query = db.GqlQuery(
"SELECT * FROM Rep WHERE author = :1",
users.get_current_user())
user = users.get_current_user()
query = db.GqlQuery(
"SELECT * FROM Rep WHERE author = :1",
user)
拥有查询对象后,可以对其调用
fetch()
,以获取列表形式的项目。或者,您也可以直接在查询上进行迭代。谢谢您的详细回答。另一个快速问题:此查询有效:query=list(db.GqlQuery(“SELECT*FROM Rep WHERE author=users.get\u current\u user())
但如果我定义user=users.get\u current\u user()
并尝试查询query=list(db.GqlQuery(“SELECT*FROM Rep WHERE author=user))
,则它不起作用。我在扫描字符串文字时出现错误SyntaxError:EOL
有什么建议吗?再次感谢!谢谢你的详细回答。另一个快速问题:此查询有效:query=list(db.GqlQuery(“SELECT*FROM Rep WHERE author=users.get\u current\u user())
但如果我定义user=users.get\u current\u user()
并尝试查询query=list(db.GqlQuery(“SELECT*FROM Rep WHERE author=user))
,则它不起作用。我在扫描字符串文字时出现错误SyntaxError:EOL
有什么建议吗?再次感谢!
SELECT * FROM Pet WHERE owner = :1
query = db.GqlQuery(
"SELECT * FROM Rep WHERE author = :1",
users.get_current_user())
user = users.get_current_user()
query = db.GqlQuery(
"SELECT * FROM Rep WHERE author = :1",
user)