I don't know how i can compare two fields or atributes in GQL.

I use python sdk and i have an object 'Room', this object have two properties one is 'user1' and the other is 'user2' so, i need check when the user connect if him is in a room or not. i want to do something like SQL in GQL like this

SELECT * FROM ROOM WHERE user1 = 'joe' or user2 = 'joe'

but i don't know how do it without OR, because the GQL doesn't work with OR operator.

if somebody can give a simple example of how i can do it, i will be really grateful.

thank you.

有帮助吗?

解决方案

The old Python datastore API (including GQL) does not support OR queries. The new NDP API does support AND and OR queries.

Note that OR queries are not native to datastore: NDB API will issue multiple queries and then combine them in memory to obtain the result.

In GQL the equivalent result would be achieved by running two queries, one for each condition, and then combining the results.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top