-
Notifications
You must be signed in to change notification settings - Fork 80
[Bug] Revert doesn't clear unapplied logs — saving after revert replays reverted transformations #49
Description
Describe the bug
Reverting a dataset doesn't clear the unapplied logs from the database. So if you revert and then save, all the old transformations get replayed on the original CSV again — basically undoing your revert.
To Reproduce
Steps to reproduce the behavior:
- Upload a CSV and open the dataset
- Add a row
- Go to File → View Checkpoints → click Revert
- Table goes back to original
- Now go to File → Save Dataset, type any commit message
- The row you reverted is back. The save replayed it.
Expected behavior
After reverting, saving should have nothing to apply. The reverted changes shouldn't come back.
The revert endpoint (POST /{dataset_id}/revert in datasets.py) copies the original CSV back to the working copy, but it doesn't touch the user_logs table. The log entries from before the revert are still sitting there with applied = False.
Then when you hit save, save_dataset does this:
logs = db.query(models.DatasetChangeLog).filter( models.DatasetChangeLog.dataset_id == dataset_id, models.DatasetChangeLog.applied == False ).order_by(models.DatasetChangeLog.timestamp).all()
The fix is just deleting the unapplied logs during revert, before the commit:
db.query(models.DatasetChangeLog).filter( models.DatasetChangeLog.dataset_id == dataset_id, models.DatasetChangeLog.applied == False ).delete()
Environment:
- OS: macOS
- Browser: Chrome
- Python: 3.13
Additional context
Any other relevant information.