Bug 149181 - PostgreSQL direct connection: Base query display '0' in TEXT field, if content of all shown fields could be read as "number" and query works with subquery as "table"
Summary: PostgreSQL direct connection: Base query display '0' in TEXT field, if conten...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.3.1.3 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-19 13:41 UTC by titanemdg
Modified: 2023-02-07 08:36 UTC (History)
2 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 titanemdg 2022-05-19 13:41:22 UTC
Description:
Sql query display '0' in one column with TEXT field. It happens when the symbol of comment -- start at the beginning of the code.
To avoid this annoying effect, commentary must be inserted after the first sql command.

Steps to Reproduce:
1. create a new query with 'New query (SQL View)'
2. Start code by inserting a comment with --
3. Go to new line and type SELECT clause
4. run the code and check: one column display '0' for all record

Actual Results:
One column with TEXT field display '0' instead of right data.

Expected Results:
Display right string not '0'


Reproducible: Always


User Profile Reset: Yes


OpenGL enabled: Yes

Additional Info:
Version: 7.3.1.3 (x64) / LibreOffice Community
Build ID: a69ca51ded25f3eefd52d7bf9a5fad8c90b87951
CPU threads: 2; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: fr-FR (fr_FR); UI: en-US
Calc: threaded
Comment 1 Robert Großkopf 2022-05-19 16:39:52 UTC
Can't confirm the buggy behavior with LO 7.3.3.2, internal HSQLDB, on OpenSUSE 15.3 64bit rpm Linux.

Started a query like
--
SELECT * FROM "Table"

and content is shown well here.

Please add an example database for this.
Comment 2 titanemdg 2022-05-20 06:27:56 UTC
(In reply to Robert Großkopf from comment #1)
> Can't confirm the buggy behavior with LO 7.3.3.2, internal HSQLDB, on
> OpenSUSE 15.3 64bit rpm Linux.
> 
> Started a query like
> --
> SELECT * FROM "Table"
> 
> and content is shown well here.
> 
> Please add an example database for this.

Your code is right for me here. But if I remove all comments then issue remains if I enclose the SELECT clause in another one , the same problem persist, one column display 0 not string:

SELECT * FROM (SELECT * FROM Table) AS L1

I check this code in PgAdmin4 and it works well, not with query in Libo Base.

For information the type of the column is TEXT but data inside is integer number with 13digits.

May be query engine interpret the data as integer according to the length or to the complexity of the code.

Listing data through 'Tables' menu works well.
Comment 3 Robert Großkopf 2022-05-20 08:05:40 UTC
Have tested this with a subquery as reported in comment2. Couldn't find any buggy behavior with an internal HSQLDB.
Then tested also with PostgreSQL (pgAdmin …) - same result with the direct connection.
How do you connect to PostgreSQL with LO Base?
Datataype "TEXT" → is it [VARCHAR]?
Comment 4 titanemdg 2022-05-20 08:13:24 UTC
(In reply to Robert Großkopf from comment #3)
> Have tested this with a subquery as reported in comment2. Couldn't find any
> buggy behavior with an internal HSQLDB.
> Then tested also with PostgreSQL (pgAdmin …) - same result with the direct
> connection.
> How do you connect to PostgreSQL with LO Base?
> Datataype "TEXT" → is it [VARCHAR]?

For connection I did :
"Connect to an existing database" -> PostgreSql
"connection string" -> dbname=theDB hostaddr=127.0.0.1 port=5432 user=postgres

The faulty field is declared like this : cg TEXT NOT NULL,
Comment 5 Robert Großkopf 2022-05-20 10:15:24 UTC
(In reply to titanemdg from comment #4)
> 
> For connection I did :
> "Connect to an existing database" -> PostgreSql
> "connection string" -> dbname=theDB hostaddr=127.0.0.1 port=5432
> user=postgres
> 
> The faulty field is declared like this : cg TEXT NOT NULL,

Seem you are using the direct connection.
Have tested with direct connection:
Tools → SQL
CREATE TABLE public.COMPANY(
   ID INT PRIMARY KEY     NOT NULL,
   NAME           TEXT    NOT NULL,
   AGE            INT     NOT NULL,
   ADDRESS        CHAR(50),
   SALARY         REAL
);

Opened the table for input data and wrote in field name: '1.234567' (an in the other fields also some data)
Started query 
--
SELECT * FROM (SELECT * FROM "public"."company" ORDER BY "id") "company"

No problem with field name, set as TEXT, here. It will be shown in LO Base and pgAdmin. No '0' instead of '1.234567'.
Comment 6 titanemdg 2022-06-22 10:32:57 UTC
I have created the table with libo base and tested column 'name' and 'address'.
Inserting and modifying  the 'Company' table was done with pgadmin4 GUI.
The code is :
SELECT * FROM (SELECT * FROM "public"."company" ORDER BY "id") "company"

TEST 1:
------------
Set
name = '1.234567'
address = '1.234567'

Result of the code in libobase are:
name -> '1,23'
address -> '1.234567'

TEST 2 :
--------------
Set
name = '1,234567'
address = '1,234567'

Result of code in libobase are:
name -> '1'
address -> '1,234567'


I am using french language settings
Comment 7 Robert Großkopf 2022-06-22 13:16:54 UTC
(In reply to titanemdg from comment #6)
> 
> TEST 1:
> ------------
> Set
> name = '1.234567'
> address = '1.234567'
> 
> Result of the code in libobase are:
> name -> '1,23'
> address -> '1.234567'

Seems the field "name" is formatted as number, see decimal separator ','. I couldn't format it as number here. Formatting is impossible in query here. Could only set horizontal align when connecting through direct connection with PostgreSQL …
Comment 8 Robert Großkopf 2022-06-22 13:33:31 UTC
Could reproduce the error.

If all entries in a TEXT field could also be recognized as a number the field will be formatted as a field for numbers in a query. It has nothing to do with direct SQL and starting with a comment.

SELECT * FROM (SELECT * FROM "public"."company") "company"

will reproduce the error directly. Has something to do with a query, which shows the content of a query. Seems the direct connection looses the information for the field and tries to detect it by the content of the column.