quru / qis

Dynamic image server for web and print
https://quruimageserver.com
GNU Affero General Public License v3.0
90 stars 7 forks source link

API - portfolio image reordering returns old value of order_num #18

Closed fozcode closed 5 years ago

fozcode commented 5 years ago

The API /api/v1/portfolios/[portfolio id]/images/[image id]/position/ does correctly set the value of order_num in the database, and does return the images in the correct order in the JSON, but the value of order_num in the JSON still contains the old value for the image that was moved.

I suspect this is a case of SQLAlchemy session caching again, we need to refresh the portfolio-image object in the session. The code already has a line for this at data_manager.py line 1582 but it doesn't seem to be working.

fozcode commented 5 years ago

The code already has a line for this at data_manager.py line 1582 but it doesn't seem to be working.

The reordering routine used its own separate db session to keep the operation atomic, so while the returned object was correctly refreshed, the object already loaded in the outer db session was not being refreshed (until now).