synopse / mORMot2

OpenSource RESTful ORM/SOA/MVC Framework for Delphi and FreePascal
https://synopse.info
Other
485 stars 122 forks source link

TRecordVersion doesn't work as expected #193

Closed avavdoshin closed 10 months ago

avavdoshin commented 1 year ago

Hello, Arnaud!

I'm stuck with TRecordVersion handling and batch updates. SQlite db via sqlite3static. Batch add works perfect, TRecordVersion increments as expected. But for batch updates via TRestBatch only few of TOrms update their TRecordVersion field, for others TRecordVersion field stays remained.

Maybe i'm doing something wrong way? First i load my TOrm from DB via CreateAndFillPrepared, then i modify some fields and add TOrm to batch via TRestBatch.add(TOrm, true) (repeat this for all my TOrm i need to change). Then I use batchSend for sending changes to db.

I can see that TRecordVersion doesn't change because i store date/time timestamp in my TOrm class and change it for every update.

avavdoshin commented 1 year ago

FPC 3.3.1, x86_64, windows 10 (codetyphon 8.0). Mormot2 github version 2.1.5479

Whole example too complicated, here is simplified part of code in attached file example.txt

avavdoshin commented 1 year ago

working simple example which you can reproduce (with results in csv) here https://gist.github.com/avavdoshin/fd1d829924940b1064a06df8f0638691 Record versions in this example doesn't changes for updates, so this changes will not be replicated to slave database.

synopse commented 10 months ago

@avavdoshin Should be fixed now with the last commit above. At least, I have included BatchUpdate() to the regression tests, which failed and now pass as expected. Sorry for the delay.

Your feedback is welcome.

synopse commented 10 months ago

Should be good now.

Please reopen if needed, or post on our forum.