diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2023-05-16 17:00:20 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-05-21 13:28:39 +0200 |
commit | 2e59eeeec00e917cc07ece4d99c7cd5c707aeea4 (patch) | |
tree | 1b26d42f3eb335859b5a885436d389e48db2e09e /wizards | |
parent | aff1919ef91200caf40c228ed71cb80ad57479bb (diff) |
ScriptForge - database.GetRows() tdf#155204 error when no data
The complete expected bheviour is:
when there is no data returned by the query,
- either GetRows() returns an empty array, (Header := False)
- or GetRows() returns an array with a single
row containing the column names only (Header := True)
In the example given in the bug report,
GetRows() gives an unexpected error.
Actually the "end-of-file" status is tested
with the isAfterLast() indicator.
It seems preferable to rely on the Boolean value
returned by the first() and next() methods applied
on the resultset.
Change-Id: Ibe97dbbcb03d45ebb9184fab2733abe4e04963a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151844
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
(cherry picked from commit d07cc6706ef3b382fa16a104c97b69bc2d2365e5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151781
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/source/sfdatabases/SF_Database.xba | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/wizards/source/sfdatabases/SF_Database.xba b/wizards/source/sfdatabases/SF_Database.xba index f0dec87c294e..4297fbc7b09a 100644 --- a/wizards/source/sfdatabases/SF_Database.xba +++ b/wizards/source/sfdatabases/SF_Database.xba @@ -310,7 +310,8 @@ Dim sSql As String ' SQL statement Dim bDirect ' Alias of DirectSQL Dim lCols As Long ' Number of columns Dim lRows As Long ' Number of rows -Dim oColumns As Object +Dim oColumns As Object ' Collection of com.sun.star.sdb.ODataColumn +Dim bRead As Boolean ' When True, next record has been read successfully Dim i As Long Const cstThisSub = "SFDatabases.Database.GetRows" Const cstSubArgs = "SQLCommand, [DirectSQL=False], [Header=False], [MaxRows=0]" @@ -365,8 +366,8 @@ Try: End If ' Load data - .first() - Do While Not .isAfterLast() And (MaxRows = 0 Or lRows < MaxRows - 1) + bRead = .first() + Do While bRead And (MaxRows = 0 Or lRows < MaxRows - 1) lRows = lRows + 1 If lRows = 0 Then ReDim vResult(0 To lRows, 0 To lCols) @@ -376,7 +377,7 @@ Try: For i = 0 To lCols vResult(lRows, i) = _GetColumnValue(oResult, i + 1) Next i - .next() + bRead = .next() Loop End With |