Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top