Bug 155529 - MariaDB/MySQL direct connection: Trying to insert NULL in NOT NULL fields will automatically changed in empty text or 0
Summary: MariaDB/MySQL direct connection: Trying to insert NULL in NOT NULL fields wil...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
6.3.0.4 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisectRequest
Depends on:
Blocks: Database-Connectivity
  Show dependency treegraph
 
Reported: 2023-05-28 08:00 UTC by Robert Großkopf
Modified: 2023-10-27 15:17 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 Robert Großkopf 2023-05-28 08:00:07 UTC
Open a connection to MariaDB (or MySQL).
Create a table by Tools → SQL:

CREATE TABLE `tblTest` (
  `ID` int NOT NULL PRIMARY KEY,
  `Name` varchar(255) COLLATE latin1_german1_ci NOT NULL,
  `Number` int NOT NULL
);

Note: No field should be NULL!
Refresh table view.
Open this table for input data.
Type a value for "ID" and for "Name" and go to next record.
No error appears.
There will automatically added '0' for "Number".
Type a value for "ID" and for "Number" and go to next record.
No error appears.
There will automatically added '' for "Name".

Open query editor to see it is an empty text:
SELECT * FROM `tblTest` WHERE `Name` IS NULL
won't show any row.
SELECT * FROM `tblTest` WHERE `Name` = ''
will show the row where no input has been made.

Try the same with JDBC-connection. JDBC-Connection won't save any data if a field is empty, which shouldn't be NULL.

No driver should automatically add a value if no value has been set by the user. Blank text in a table is NULL by default, blank fields in a field for any other content is NULL.

If I create a form it will be possible to set the properties for an empty field. Default here is to send NULL to the database. But this won't work with internal driver for MySQL/MariaDB.

Tested here with LO 7.4.7.2 on OpenSUSE 15.4 64bit rpm Linux
Same behavior with LO 7.5.3.2.
Tested also with LO 6.3.0.4 - same behavior. This is the first version with direct connection to MariaDB integrated and possibility to input new data in this kind of table.
Comment 1 Adam664 2023-06-14 17:55:27 UTC
Confirming the bug is present when using a MariaDB direct connection in:

Version: 7.5.3.2 (X86_64)
Build ID: 50(Build:2)
CPU threads: 1; OS: Linux 6.3; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

and

Version: 7.7.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 5a2c6f4df7149f8c1f543f120fe19bd66abfc189
CPU threads: 1; OS: Linux 6.3; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

The bug is not present when using a JDBC connection, so this might have something to do with the MariaDB direct connection.

A JDBC connection will open the original table with blank fields, but will enforce the NOT NULL condition on newly input data.
Comment 2 Alex Thurgood 2023-06-15 09:04:49 UTC
I can reproduce this in a direct connection against a MySQL server instance with

Version: 7.5.1.2 (AARCH64) / LibreOffice Community
Build ID: fcbaee479e84c6cd81291587d2ee68cba099e129
CPU threads: 8; OS: Mac OS X 13.4; UI render: Skia/Raster; VCL: osx
Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR
Calc: threaded
Comment 3 Alex Thurgood 2023-06-15 09:09:20 UTC
I don't recall this behaviour in older versions of LO, but can not test them on macOS. This would appear to be a regression.
Comment 4 Robert Großkopf 2023-09-21 06:53:33 UTC
Tested also with a date: Will insert '0000-00-00', which is a wrong date and will be shown in Base frontend as '03.01.-1'