Bug 167546 - Incorrect execution of SQL queries for SQLite
Summary: Incorrect execution of SQL queries for SQLite
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
25.2.4.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-17 15:40 UTC by Vladimir Sokolinskiy
Modified: 2025-07-17 15:48 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
test.odb (2.85 KB, application/vnd.sun.xml.base)
2025-07-17 15:40 UTC, Vladimir Sokolinskiy
Details
test.db (8.00 KB, application/vnd.sqlite3)
2025-07-17 15:41 UTC, Vladimir Sokolinskiy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Sokolinskiy 2025-07-17 15:40:37 UTC
Created attachment 201840 [details]
test.odb

Steps to reproduce.

1. Download the attached files test.odb and test.db to a folder (in my case it's C:\temp).
The SQLite file test.db contains one table "test" with one field "name". The "test" table has one record with the value of the field "name" equal to "A".

2. Install jdbc driver for SQLite. I downloaded the driver from the link [1].

3. Change the path to the test.db file in test.odb. Test the connection.

4. Run the following macro (after adjusting the path C:\temp).
A new Calc file will be created, which will contain the result of the SQL query.

Cell C2 is equal to 0.
Must be "A".

Sub TestSQLite()
  Dim fileURL As String, sqlQuery As String
  Dim oDoc As Object, oRange As Object
  Dim props(3) As New com.sun.star.beans.PropertyValue 
 
  fileURL=ConvertToURL("C:\Temp\Test.odb")  ' ** !! **
  
  sqlQuery="Select name, name || '' strexp   from Test"

  oDoc = StarDesktop.LoadComponentFromUrl("private:factory/scalc", "_blank", 0, Array())
 
  props(0).Name="DatabaseName" : props(0).Value=FileURL
  props(1).Name="SourceType"   : props(1).Value=1
  props(2).Name="SourceObject" : props(2).Value=sqlQuery
  props(3).Name="IsNative"     : props(3).Value=True
   
  oRange=oDoc.Sheets(0).GetCellRangeByName("A1")
  oRange.doImport props
End Sub


[1]. https://github.com/xerial/sqlite-jdbc
Comment 1 Vladimir Sokolinskiy 2025-07-17 15:41:10 UTC
Created attachment 201841 [details]
test.db
Comment 2 Vladimir Sokolinskiy 2025-07-17 15:48:29 UTC
Correction to the opening message.
Instead of
Cell C2 is equal to 0.
should read
Cell B2 is equal to 0.