Jump to content

The custom attributes of any entity type are not getting fetched correctly


Remus Avram

Recommended Posts

Hi all,

I have a shot queried from DB via ftrack_api. I update a custom attribute of the respective shot. Then, in the same session, I query the shot again.

The custom attribute of the respective shot is not updated even after I queried the shot again.

Please find below an example:

    def test_query_custom_attributes(self):

        def update_custom_attribute(test_asset):
            new_session = ftrack_api.Session()
            same_test_asset = new_session.query("AssetBuild where id is '{0}'".format(test_asset["id"])).one()
            same_test_asset['custom_attributes']['delivery_name'] = "unittest"
            new_session.commit()

        test_asset = self._session.query("AssetBuild").first()
        delivery_name = test_asset['custom_attributes']['delivery_name']

        update_custom_attribute(test_asset)

        test_asset = self._session.query("AssetBuild where id is '{0}'".format(test_asset["id"])).one()
        new_delivery_name = test_asset['custom_attributes']['delivery_name']

        self.assertNotEqual(delivery_name, new_delivery_name)

        self._session.cache.clear()
        test_asset = self._session.query("AssetBuild where id is '{0}'".format(test_asset["id"])).one()
        new_delivery_name = test_asset['custom_attributes']['delivery_name']
        self.assertNotEqual(delivery_name, new_delivery_name)

Clearing the cache and fetching the shot again from the database works.

Link to comment
Share on other sites

Thanks @Eric Hermelin for taking a look!

Cleaning the session or re-populating the data works as a workaround.

But for long term I hope it will fetch the right data once we query the shot again.

There are too many places where we need to patch it, and for users which don't have experience in programming (artists), it's difficult to explain.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...