query with "has" and "any"
1 1

3 posts in this topic

I'm having trouble understanding the use of "has" and "any" as it is described in the api docs at http://ftrack.rtd.ftrack.com/en/stable/developing/api/query_syntax.html#filtering-on-relationships

The example for "has" is:

   select id from Note where author has (first_name is "Jane" and last_name is "Doe")

and the text states that writing that query without "has" wouldn't have the desired effect of returning notes from Jane Doe. But why is that? The way I would write this query without "has" would be:

   select id from Note where author.first_name is "Jane" and author.last_name is "Doe"

How would this query return notes by "Jane Smith" or "John Doe"? I'm having trouble following along.

I now I could play around with queries on our server but I don't really know what a correct result would look like so I'm asking this on the forum instead :-)

Share this post


Link to post
Share on other sites

You're absolutely right. The example is wrong and I will update it.

What is said in the example is true for non-scalar relations like metadata or children, e.g:

Task where metadata any (key is "foo" and value is "bar")

In this case using "any" guarantees that we're not getting tasks that have one metadata item with key "foo" and another metadata item with value "bar". We're looking for tasks with metadata items that have key "foo" and value "bar". 

Thanks for pointing this out!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
1 1