ScriptForge (SF_Dataset) fix GetRows() in chunks

Two bugs are fixed with this commit:

1. when rows in a dataset are read in chunks,
   one record is skipped errorneously between
   every two successive chunks.

2. In updatable datasets, the updatable fields
   need to be identified. This is done at
   dataset creation.
   Before: the IsDefinitelyWritable criterion was
           used, valid for Firebird, not for HSQL
   After:  the IsWritable criterion is used,
           valid for both.

The correction in Basic is valid as well for Python.
Documentation is unchanged.

Change-Id: I990c02aaa8a93123a7e669b1294605fa19780167
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160163
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
This commit is contained in:
Jean-Pierre Ledure 2023-11-30 17:11:13 +01:00
parent c89c4ebe49
commit 07036eea50
2 changed files with 5 additions and 4 deletions

View file

@ -28,7 +28,7 @@ Option Explicit
&apos;&apos;&apos; Transaction handling
&apos;&apos;&apos; Changes to data remain reversible until the moment the running script instructs the database to commit them.
&apos;&apos;&apos; The implicit (default) behaviour is that commit takes place after the execution of every single SQL statement.
&apos;&apos;&apos; The choice can be made (SetTranactionMode()) to take commitments manually.
&apos;&apos;&apos; The choice can be made (SetTransactionMode()) to take commitments manually.
&apos;&apos;&apos; The Commit() and Rollback() statements delimit transactions.
&apos;&apos;&apos;
&apos;&apos;&apos; Service invocation and usage:

View file

@ -585,6 +585,7 @@ Check:
If Not ScriptForge.SF_Utils._Validate(Header, &quot;Header&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
If Not ScriptForge.SF_Utils._Validate(MaxRows, &quot;MaxRows&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
End If
If MaxRows &lt; 0 Then MaxRows = 1
Try:
With _RowSet
@ -608,7 +609,7 @@ Try:
End If
&apos; Load data
Do While bRead And (MaxRows = 0 Or lRows &lt; MaxRows - 1)
Do While bRead
lRows = lRows + 1
If lRows = 0 Then
ReDim vResult(0 To lRows, 0 To lCols)
@ -618,7 +619,7 @@ Try:
For i = 0 To lCols
vResult(lRows, i) = _ParentDatabase._GetColumnValue(_RowSet, i + 1)
Next i
bRead = .next()
If MaxRows = 0 Or lRows &lt; MaxRows - 1 Then bRead = .next() Else bRead = False
Loop
Else
@ -1343,7 +1344,7 @@ Try:
&apos; Field names
sFields = sFields &amp; &quot;,&quot; &amp; .Name
&apos; Updatable field names
If Not _ReadOnly And .isDefinitelyWritable And Not .IsAutoIncrement Then sUpdatableFields = sUpdatableFields &amp; &quot;,&quot; &amp; .Name
If Not _ReadOnly And .IsWritable And Not .IsAutoIncrement Then sUpdatableFields = sUpdatableFields &amp; &quot;,&quot; &amp; .Name
&apos; Default values
_DefaultValues(i) = _ConvertDefaultValue(oColumn)
&apos; AutoValue