Nebukadhezer 2 Report post Posted November 9, 2020 Hey I was wondering if one can get all Tasks/Versions etc by a group name if any assignee is in that group... GROUP_NAME = "Ape" test = session.query("AssetVersion where task.assignments.resource.memberships.group.name is {}".format(GROUP_NAME)).one() This results in a KeyError("Multiple schemas [u'Group', u'User'] found for relationship memberships.") Can I narrow down that I only want type group ? Cheers Johannes Share this post Link to post Share on other sites
Steve Petterborg 4 Report post Posted November 9, 2020 Hi Johannes, Towards the bottom of this page (search for "subclass") we show some examples of casting a result to a single type: https://help.ftrack.com/en/articles/1040506-query-syntax In your case, I believe you query string would be: "AssetVersion where task.assignments.resource[User].memberships.group.name is {}" 1 Nebukadhezer reacted to this Share this post Link to post Share on other sites
PeterH 2 Report post Posted January 4 Hi, I've been trying to use casting with the `populate` command, but I can't find anything that works. Is it not supported or am I doing something wrong? >>> shot = session.get('Shot', shot_id) >>> session.populate(shot, 'children.status') ServerError: Server reported error: KeyError("Multiple schemas [u'Project', u'TypedContext'] found for relationship u'status'.") >>> session.populate(shot, 'children[Project].status') >>> session.populate(shot, 'children[TypedContext].status') ServerError: Server reported error: KeyError(u'children[Project]') >>> session.populate(shot, 'children.status[Project]') >>> session.populate(shot, 'children.status[TypedContext]') ServerError: Server reported error: KeyError(u"No attribute u'status[Project]' exists for schema u'Context'." Share this post Link to post Share on other sites
Steve Petterborg 4 Report post Posted January 4 Hey Peter, What you're running in to is the fact that populate() constructs a query using that attribute string, and we don't support typecasting in a projection. see https://bitbucket.org/ftrack/ftrack-python-api/src/23f582cd146e71f871ba8a17da30c0ad831de836/source/ftrack_api/session.py#lines-1070 We do support passing a list, tuple or QueryResult, so my workaround would be something like the populate line in this snippet. The rest is just included to set up my example / test. shot = session.query('select children from Shot where children is_not None').first() session.populate(shot['children'][:], 'status') with session.auto_populating(False): print(shot['children'][0]['name']) print(shot['children'][0]['status']) I suppose the root cause of all this is that children maps to Contexts, which can include Projects, which themselves do not have statuses. 1 PeterH reacted to this Share this post Link to post Share on other sites