Bug 152687 - Form Combobox Not Working With Postgres
Summary: Form Combobox Not Working With Postgres
Status: NEEDINFO
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.4.3.2 release
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-26 13:25 UTC by Alexander
Modified: 2024-06-13 03:17 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
control properties (35.26 KB, image/jpeg)
2022-12-26 13:26 UTC, Alexander
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2022-12-26 13:25:25 UTC
Description:
Given a postgres database as a backend
And a One-to-Many table relation
When I create a form with a combobox
Then my combobox does not work - it shows the FK ID value instead of a label.
And when I select another value it treats it as a string and produces an error.




Steps to Reproduce:

0. Run a postgres on docker on localhost
1. Create the following tables in postgres

create table user_group (
    group_id serial primary key,
    group_name varchar
);

create table my_user (
    id serial primary key,
    group_id integer,
    constraint fk_group foreign key (group_id) references user_group(group_id)
);

insert into user_group (group_name) values ('A'), ('B');
insert into my_user (group_id) values (1);

2. Connect to and register your database with "base"
3. Create a form (with or without wizzard) bound to the my_user table
4. Add a combobox related to the user group
5. Use "group_name" as display field
6. Set to update "group_id" in the my_user table
7. Try changing the user's group in "normal" mode

Actual Results:

Error code: 1

pq_driver: [PGRES_FATAL_ERROR]ERROR:  insert or update on table "my_user" violates foreign key constraint "fk_group"
DETAIL:  Key (group_id)=(0) is not present in table "user_group".
 (caused by statement 'UPDATE "public"."my_user" SET "group_id" = '0' WHERE "id" = '1'') at /build/libreoffice-fresh/src/libreoffice-7.4.3.2/connectivity/source/drivers/postgresql/pq_statement.cxx:261

Expected Results:
The group of the user should be updated.
It should be possible to add new groups


Reproducible: Always


User Profile Reset: Yes

Additional Info:
N/A
Comment 1 Alexander 2022-12-26 13:26:35 UTC
Created attachment 184354 [details]
control properties
Comment 2 Robert Großkopf 2023-01-10 16:13:22 UTC
Only had a look at the screenshot:
You have connected the combo box to a field called "group_id". This group_id is an INTEGER, defined in your table. Then you try to fill it with "group_name" - defined as VARCHAR. The field itself will only show INTEGER.

Seems you are looking for a list box, not a combo box. List boxes will show the group_name and save the group_id.
Try a list box with this code:

SELECT "group_name", "group_id" FROM "public"."user_group"

Bound field in data should be default (1). So "group_id" will be saved in the table while "group_name" will be shown.
Comment 3 Robert Großkopf 2023-12-15 16:46:00 UTC
No reaction since nearly a year. Could we close this one as WORKSFORME?
Comment 4 QA Administrators 2024-06-13 03:17:33 UTC
Dear Alexander,

This bug has been in NEEDINFO status with no change for at least
6 months. Please provide the requested information as soon as
possible and mark the bug as UNCONFIRMED. Due to regular bug
tracker maintenance, if the bug is still in NEEDINFO status with
no change in 30 days the QA team will close the bug as INSUFFICIENTDATA
due to lack of needed information.

For more information about our NEEDINFO policy please read the
wiki located here:
https://wiki.documentfoundation.org/QA/Bugzilla/Fields/Status/NEEDINFO

If you have already provided the requested information, please
mark the bug as UNCONFIRMED so that the QA team knows that the
bug is ready to be confirmed.
 
Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-NeedInfo-Ping