Python GQL(谷歌应用程序引擎)中的条件返回错误为什么?
当我在GQL中使用OR条件时,它返回错误消息:错误消息“BadQueryError:Parse error:在symbol或处不需要其他符号。为什么Python GQL(谷歌应用程序引擎)中的条件返回错误为什么?,python,google-app-engine,gql,gqlquery,Python,Google App Engine,Gql,Gqlquery,当我在GQL中使用OR条件时,它返回错误消息:错误消息“BadQueryError:Parse error:在symbol或处不需要其他符号。为什么 db.GqlQuery("Select * from vendor where access='public' OR organisation_id='"+ orgid +"'") 文档明确指出GQL没有OR操作符 您可以这样做..进行两次查询并合并结果 vendors=vendor.all() pub_vendors = vendors
db.GqlQuery("Select * from vendor where access='public' OR organisation_id='"+ orgid +"'")
文档明确指出GQL没有OR操作符
您可以这样做..进行两次查询并合并结果
vendors=vendor.all()
pub_vendors = vendors.filter("access = ","public")
vendors=vendor.all()
org_vendors = vendors.filter("organisation_id = ",orgid)
results = pub_vendors.extend(org_vendors)
您的示例将是AND,并且几乎肯定不是OP想要的。如果供应商有datetime属性,我将如何使用GQL按时间对“结果”排序(通常使用
按时间排序ASC/DESC
)?除非有巧妙的技巧,否则必须以编程方式执行AttributeError:“Query”对象没有属性“extend”
。您需要调用fetch
,然后才能extend
。
vendors=vendor.all()
pub_vendors = vendors.filter("access = ","public")
vendors=vendor.all()
org_vendors = vendors.filter("organisation_id = ",orgid)
results = pub_vendors.extend(org_vendors)