flame: fixing getting already created entity

This commit is contained in:
Jakub Jezek 2022-02-24 11:42:07 +01:00
parent 2cfbe3282c
commit e0670d34eb
No known key found for this signature in database
GPG key ID: D8548FBF690B100A

View file

@ -389,13 +389,17 @@ class FtrackEntityOperator:
return entity
def get_ftrack_entity(self, session, type, name, parent):
query = '{} where name is "{}" and project_id is "{}"'.format(
query_no_parent = '{} where name is "{}" and project_id is "{}"'.format(
type, name, self.project_entity["id"])
query_with_parent = (
'{} where name is "{}" and project_id is "{}" '
'and parent_id is {}').format(
type, name, self.project_entity["id"], parent["id"])
try:
entity = session.query(query).one()
except Exception:
entity = None
entity = (
session.query(query_no_parent).first() or
session.query(query_with_parent).first()
)
# if entity doesnt exist then create one
if not entity: