https://bugs.documentfoundation.org/show_bug.cgi?id=156238
Bug ID: 156238
Summary: Python SFDatabases.Database.GetRows() crashes when no
data is available
Product: LibreOffice
Version: 7.3.7.2 release
Hardware: x86-64 (AMD64)
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: Base
Assignee: [email protected]
Reporter: [email protected]
Description:
I write python macro embed in Calc which: create database, insert data and
select data.
An Libreoffice error window is displayed when there is no data in the database
(SELECT statement). Trying to catch an exception doesn't help.
Steps to Reproduce:
1. Install APSO
2. Open the attached file
3. Run "organise python script", select embedded modul "test", run "Python
shell"
4. In shell type test1() + enter
Actual Results:
>>> test1()
/home/sznik/python_projekty/LibreOffice/test.odb
Connection to Base successful
query ='CREATE TABLE "tickers" ("id" INTEGER GENERATED BY DEFAULT AS
IDENTITY(START WITH 0) NOT NULL PRIMARY KEY, "ticker" VARCHAR(50) NOT NULL,
"currency" VARCHAR(10) NOT NULL)'
Query executed successfully
query ='INSERT INTO "tickers" ("ticker", "currency") VALUES (\'a\', \'aa\')'
Query executed successfully
query ='SELECT "id" FROM "tickers" WHERE "ticker" = \'a\' '
Query executed successfully
execute_read_query(connection, query) =((0,),)
query ='SELECT "id" FROM "tickers" WHERE "ticker" = \'b\' '
Traceback (most recent call last):
File "/usr/lib/python3.10/code.py", line 90, in runcode
exec(code, self.locals)
File "<console>", line 1, in <module>
File "/home/sznik/.config/libreoffice/4/user/Scripts/python/test.py", line
61, in test1
print(f'{execute_read_query(connection, query) =}\n')
File "/home/sznik/.config/libreoffice/4/user/Scripts/python/test.py", line
33, in execute_read_query
result = connection.GetRows(query, directsql=True)
File "/usr/lib/libreoffice/program/scriptforge.py", line 1603, in GetRows
return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'GetRows',
sqlcommand, directsql, header, maxrows)
File "/usr/lib/libreoffice/program/scriptforge.py", line 546, in ExecMethod
return self.EXEC(self.objectreference, flags, methodname, *args)
File "/usr/lib/libreoffice/program/scriptforge.py", line 306, in
InvokeBasicService
raise RuntimeError("The execution of the method '" + method + "' failed.
Execution stops.")
RuntimeError: The execution of the method 'GetRows' failed. Execution stops.
>>>
Expected Results:
>>> test1()
/home/sznik/python_projekty/LibreOffice/test.odb
Connection to Base successful
query ='CREATE TABLE "tickers" ("id" INTEGER GENERATED BY DEFAULT AS
IDENTITY(START WITH 0) NOT NULL PRIMARY KEY, "ticker" VARCHAR(50) NOT NULL,
"currency" VARCHAR(10) NOT NULL)'
Query executed successfully
query ='INSERT INTO "tickers" ("ticker", "currency") VALUES (\'a\', \'aa\')'
Query executed successfully
query ='SELECT "id" FROM "tickers" WHERE "ticker" = \'a\' '
Query executed successfully
execute_read_query(connection, query) =((0,),)
query ='SELECT "id" FROM "tickers" WHERE "ticker" = \'b\' '
Query executed successfully
execute_read_query(connection, query) =()
>>>
Reproducible: Always
User Profile Reset: No
Additional Info:
Version: 7.3.7.2 / LibreOffice Community
Build ID: 30(Build:2)
CPU threads: 4; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: pl-PL (pl_PL.UTF-8); UI: pl-PL
Ubuntu package version: 1:7.3.7-0ubuntu0.22.04.3
Calc: threaded
--
You are receiving this mail because:
You are the assignee for the bug.