From 07036eea5089feae511145412d7105cb76c1955a Mon Sep 17 00:00:00 2001 From: Jean-Pierre Ledure Date: Thu, 30 Nov 2023 17:11:13 +0100 Subject: [PATCH] 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 Tested-by: Jenkins --- wizards/source/sfdatabases/SF_Database.xba | 2 +- wizards/source/sfdatabases/SF_Dataset.xba | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wizards/source/sfdatabases/SF_Database.xba b/wizards/source/sfdatabases/SF_Database.xba index fa5d0778b873..ff0eafc5b783 100644 --- a/wizards/source/sfdatabases/SF_Database.xba +++ b/wizards/source/sfdatabases/SF_Database.xba @@ -28,7 +28,7 @@ Option Explicit ''' Transaction handling ''' Changes to data remain reversible until the moment the running script instructs the database to commit them. ''' The implicit (default) behaviour is that commit takes place after the execution of every single SQL statement. -''' The choice can be made (SetTranactionMode()) to take commitments manually. +''' The choice can be made (SetTransactionMode()) to take commitments manually. ''' The Commit() and Rollback() statements delimit transactions. ''' ''' Service invocation and usage: diff --git a/wizards/source/sfdatabases/SF_Dataset.xba b/wizards/source/sfdatabases/SF_Dataset.xba index e9eb050d93f0..02b3d35affd9 100644 --- a/wizards/source/sfdatabases/SF_Dataset.xba +++ b/wizards/source/sfdatabases/SF_Dataset.xba @@ -585,6 +585,7 @@ Check: If Not ScriptForge.SF_Utils._Validate(Header, "Header", ScriptForge.V_BOOLEAN) Then GoTo Finally If Not ScriptForge.SF_Utils._Validate(MaxRows, "MaxRows", ScriptForge.V_NUMERIC) Then GoTo Finally End If + If MaxRows < 0 Then MaxRows = 1 Try: With _RowSet @@ -608,7 +609,7 @@ Try: End If ' Load data - Do While bRead And (MaxRows = 0 Or lRows < 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 < MaxRows - 1 Then bRead = .next() Else bRead = False Loop Else @@ -1343,7 +1344,7 @@ Try: ' Field names sFields = sFields & "," & .Name ' Updatable field names - If Not _ReadOnly And .isDefinitelyWritable And Not .IsAutoIncrement Then sUpdatableFields = sUpdatableFields & "," & .Name + If Not _ReadOnly And .IsWritable And Not .IsAutoIncrement Then sUpdatableFields = sUpdatableFields & "," & .Name ' Default values _DefaultValues(i) = _ConvertDefaultValue(oColumn) ' AutoValue