rollBackEditedRecords

I’ve noticed that in some cases a databaseManager.rollBackEditedRecords() deletes previously saved records :cry:

Step 1) insert some new records (A)
2) databaseManager.saveData()
3) databaseManager.setAutoSave(false)
4) insert some new records (B)
5) databaseManager.rollBackEditedRecords()
6) databaseManager.setAutoSave(true)

Records A and B are gone after step 6. No Servoy database transactions are active.

Servoy Developer 5.2.2

Anyone seen this ?

Regards,

Hi Lambert,

My guess is that in step 2 the saveDate() returned false and the records where not saved.
Do you always check for the result ?

Hi Robert,

I went into debug mode : The saveData() of step 2 returns true, databaseManager.getEditedrecords() is empty after the save and I see the records (A) in the data SQL explorer (as it should after saveData()) !

After step 6 and refreshing the data SQL explorer the records (A) are gone… If I don’t use the rollbackEditedRecords() (step 5) everything is fine…

Quite disturbing. It looks like the internal Servoy administration of edited records is not (yet ?) correctly updated.

Regards,

That indeed doesn’t sound right. Can you file a case for this?

Paul

Hi Paul,

Yep, Case ID 337601.

Regards,

Lambert,

There must be something else going on, because databasemanager.rollbackEditedrecords() does not delete anything in the db, it just reverts changes made in memory.

Rob

Hi Lambert,

Can you check that after step 2 that when it returns true the newly created records are really in the back-end database ?

Hi Robert,

Yes, they are present in de back-end database.

I filed a case but I don’t have the time to isolate the problem into a sample solution.
I rewrote my code now so that I don’t have to use the rollbackEditedRecords() in step 5 (first test and if ok then write is BTW always better)

Thanks for thinking along with me.

Regards,

Hi Lambert,

Interesting…so they are in the database and then gets deleted. Are you sure you don’t use a DB transaction that you rollback ?
Also check the statistics page in the Servoy admin pages to see if there is a delete.