#1 2015-09-15 07:58:30

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 357

issue with Batch after update

After update mORMot I get an issue with TSQLRestBatch:

The Batch consists of several tables.

In mORMot line 37869:

Value := Model.TableProps[TableIndex].Props.
            SaveSimpleFieldsFromJsonArray(Sent,EndOfObject,true);

TableIndex = -1 and Exception will be raised.

If I replace TableIndex with RunTableIndex Batch work as expected.

Offline

#2 2015-09-15 08:02:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: issue with Batch after update

This was indeed a regression, in such cases.

Should be fixed by http://synopse.info/fossil/info/1eeadc4628

Thanks for the report!

Offline

#3 2015-09-15 08:39:36

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 357

Re: issue with Batch after update

Thanks for your quick solution.

Is it possible to send such a Batch (with several tables included) under one implicit transaction?

Offline

#4 2015-09-15 08:43:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: issue with Batch after update

What do you call "implicit"?
If you mean "automatically generated", yes it is possible.
Just define the AutomaticTransactionPerRow parameter, to some number, e.g. 10000:

    // - you should better set AutomaticTransactionPerRow > 0 to execute all
    //   BATCH processes within an unique transaction grouped by a given number
    //   of rows, on the server side - set AutomaticTransactionPerRow=maxInt if
    //   you want one huge transaction, or set a convenient value (e.g. 10000)
    //   depending on the back-end database engine abilities, if you want to
    //   retain the transaction log file small enough for the database engine
    // - BatchOptions could be set to tune the SQL execution, e.g. force INSERT
    //   OR IGNORE on internal SQLite3 engine
    constructor Create(aRest: TSQLRest; aTable: TSQLRecordClass;
      AutomaticTransactionPerRow: cardinal=0; Options: TSQLRestBatchOptions=[]);

In fact, manual transactions outside the BATCH are not a good idea, and may very likely create confusion, depending on how they are executed on the server side (some external DB may e.g. use its per-thread transaction).
This AutomaticTransactionPerRow parameter, in conjunction with a Batch, is the preferred way of creating transactions, from the ORM point of view.

Offline

#5 2015-09-15 08:59:14

danielkuettner
Member
From: Germany
Registered: 2014-08-06
Posts: 357

Re: issue with Batch after update

Ok, that's what I wanted to know!

Thank you and have a nice day.

Offline

Board footer

Powered by FluxBB