Bug 115049 - DatabaseImportDescriptors still parse SQL, even when IsNative is set to True
Summary: DatabaseImportDescriptors still parse SQL, even when IsNative is set to True
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.4.4.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-16 17:41 UTC by jan.benda
Modified: 2024-03-06 15:03 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jan.benda 2018-01-16 17:41:51 UTC
First reported on 2007-01-11 13:53:36 UTC 
https://bz.apache.org/ooo/show_bug.cgi?id=73375

If I set a DatabaseImportDescriptor for a database range in calc to
an SQL statement, when I do the import, it appears that calc *always* attempts
to parse the SQL, even when the IsNative flag is set to True. This is a problem
because I want to send a stored function query to a mysql database; LO
cannot parse such a query, so it must be send in Native mode (which works in
other situations like in Base queries).

Here's a basic script to show what I'm doing:

Sub Main
dbRange = ThisComponent.DatabaseRanges.getByName("mydbRange")
desc() = dbRange.ImportDescriptor
desc(0).Name = "DatabaseName"
desc(0).Value = "MyDB"
desc(1).Name = "SourceType"
desc(1).Value = com.sun.star.sheet.DataImportMode.SQL
desc(2).Name = "SourceObject"
desc(2).Value = "select 
    date_format(
        adddate('2011-1-1', @num:=@num+1), 
        '%Y-%m-%d'
    ) date
from 
    information_schema.tables,
    (select @num:=-1) num
limit 
    365"
desc(3).Name = "IsNative"
desc(3).Value = True
dbRange.getReferredCells.doImport(desc())
End Sub

This macro fails with "Syntax error in SQL expression". 
Type: com.sun.star.container.NoSuchElementException
Message: .

However, the query works in mysql natively and from LO-Base, provided
Native mode is selected.
Comment 1 Buovjaga 2018-02-11 14:00:23 UTC
Setting to NEW as it's coming from an existing report.
Comment 2 QA Administrators 2019-02-12 03:42:43 UTC Comment hidden (obsolete)
Comment 3 QA Administrators 2021-02-12 04:14:57 UTC Comment hidden (obsolete)
Comment 4 oli 2021-03-18 10:44:23 UTC
bug is still present

Version: 7.1.1.2 (x64) / LibreOffice Community
Build ID: fe0b08f4af1bacafe4c7ecc87ce55bb426164676
CPU threads: 16; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: CL
Comment 5 QA Administrators 2023-03-19 03:25:30 UTC Comment hidden (obsolete)
Comment 6 Vladimir Sokolinskiy 2024-03-06 15:03:33 UTC
Repro with PostgreSQL.

Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 6; OS: Windows 10.0 Build 19045; UI render: default; VCL: win
Locale: ru-RU (ru_RU); UI: ru-RU
Calc: threaded