Pre-projecting nested data
1 1

4 posts in this topic

Hey all,

I'm trying to gather the names of lists with a specific custom attribute that shots belong to. My question is two-fold:

1) Is there a way to return JUST the values I'm after in these queries?

For example in the query below,  from each shot I want only the lists with the "flagRV" attribute returned. Right now it returns all lists associated with the shot:

select name, project.name, project_id,
lists.name, lists.custom_attributes
from Shot
where
project.name = {0} and
name in ({1}) and
lists.custom_attributes any (key is "flagRV" and value is "True")

In this next query, I've reversed the logic to lookup by lists, but only want items (shots) returned that are mentioned in the query - right now it returns ALL items/shots in the resulting lists:

select name, project.name, project_id, items.name
from TypedContextList
where
project.name = {0} and
custom_attributes any (key is "flagRV" and value is "True") and
items any (name in ({1}))

 

2) Assuming the answer to my first question is NO, is there a way to pre-project data for nested items? With the queries above, only the shot/list ids are returned, even though I'm trying to explicitly return the names. In this scenario, lazy queries are not an option, so the data has to be pre-projected.

 

Thanks! :)

Share this post


Link to post
Share on other sites

Hi Justin,

Do you want to retrieve both the shot and the list in the same query? But nothing else from the collections - i.e. not all entries in the list and not all lists).

Unfortunately I'm not sure this can be done with less than two queries.

 

Share this post


Link to post
Share on other sites

Yes, I'm trying to just return the list names a shot belongs to that have specific custom attribute values. It doesn't look like I'm able to do what I'm after in one query without having to do a bunch of post-processing/iterating through the lists.

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