Bug 130672 - base sql query parameter with negative value fails
Summary: base sql query parameter with negative value fails
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
6.3.4.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-14 18:41 UTC by Wayne Davis
Modified: 2024-02-17 10:21 UTC (History)
1 user (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 Wayne Davis 2020-02-14 18:41:02 UTC
Description:
Simple example:
SELECT * FROM "MediaInfo" WHERE "aid" = :P1
The "aid" column is integer and has some negative integers in it. When I run the query and enter a positive integer it works but finds no records if I enter a negative. It does work when I replace :P1 with either '-1030' or just -1030.
Sliderule gave two workarounds:
SELECT * FROM "MediaInfo" WHERE "aid" = :P1*1
or SELECT * FROM "MediaInfo" WHERE "aid" IN ( :P1 )
He says it's an issue with Base OpenOffice / LibreOffice database parser.

Steps to Reproduce:
1. Create table1 with "ID", "AID" columns, both integer.  Create data rows, with negative numbers for "aid", ex:
ID   AID
123 -1030
124  235
666 -9999
2. Create query SELECT * FROM "table1" WHERE "aid" = :P1
3. Run query, enter -1030 for prompt.


Actual Results:
No records found.

Expected Results:
123, -1030


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 6.3.4.2 (x64)
Build ID: 60da17e045e08f1793c57c00ba83cdfce946d0aa
CPU threads: 4; OS: Windows 10.0; UI render: default; VCL: win; 
Locale: en-US (en_US); UI-Language: en-US
Calc: threaded
Comment 1 Robert Großkopf 2020-02-15 15:59:37 UTC
Could confirm the buggy behavior with the internal database HSQLDB. Seems the parameter isn't set as Integer.

SELECT * FROM "table1" WHERE "aid" = CAST(:P1 AS INTEGER)
will work. Multiplication with '1' will do the same.
SELECT "aid", :P1 AS "T" FROM "table1" WHERE "aid" = :P1
will work also.

With internal Firebird the bug appears also, but there is no known workaround.

Tested with LO 6.4.0.3 on OpenSUSE 15.1 64bit rpm Linux
Comment 2 Robert Großkopf 2020-02-16 08:16:25 UTC
(In reply to Robert Großkopf from comment #1)
> 
> With internal Firebird the bug appears also, but there is no known
> workaround.

Workaround with Firebird:

SELECT * FROM "table1" WHERE CAST("aid" AS VARCHAR(10)) = :P1
Comment 3 QA Administrators 2022-02-16 03:35:30 UTC Comment hidden (obsolete)
Comment 4 Robert Großkopf 2022-02-16 06:56:23 UTC
Bug still exists in LO 7.3.1.1 on OpenSUSE 64bit rpm Linux.

Seems the parser sets negative values to "VARCHAR". Its a typical bug of the dialog for the parameter. In older versions before LO 4.4 it also set empty strings instead of NULL. See bug 86852
Comment 5 QA Administrators 2024-02-17 03:13:07 UTC Comment hidden (obsolete)
Comment 6 Robert Großkopf 2024-02-17 10:21:41 UTC
Bug still exists in LO 24.2.0.3 on OpenSUSE 64bit rpm Linux.