Remus Avram Posted October 27, 2017 Report Share Posted October 27, 2017 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 More sharing options...
Eric Hermelin Posted October 27, 2017 Report Share Posted October 27, 2017 Hi Remus, I will take a deeper look at this, in the meantime could you use Session.populate, it should fore a reload of the data del test_asset['custom_attributes'] self._session.populate( test_asset, 'custom_attributes' ) cheers Eric Link to comment Share on other sites More sharing options...
Remus Avram Posted October 27, 2017 Author Report Share Posted October 27, 2017 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.