Bug 112023 - Copying data from Base truncates precision to the shown format
Summary: Copying data from Base truncates precision to the shown format
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-25 11:14 UTC by Lars Jødal
Modified: 2023-12-29 06:11 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Small database with high-precision data (3.72 KB, application/vnd.sun.xml.base)
2017-08-25 11:14 UTC, Lars Jødal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Jødal 2017-08-25 11:14:38 UTC
Created attachment 135786 [details]
Small database with high-precision data

In Base, copying a table or query with standard "Copy", the data are only copied to the precision defined by the formatting, not the full precision. For instance, standard numeric format shows two decimal places, so a data entry containing the number 3.1415 will be copied as 3.14, resulting in loss of precision.

For seeing the behaviour, open the attached small database and copy "Table1" into e.g. a Calc spreadsheet. The database contains the data

    MyTimestamp            MyDouble
    01-01-2015 00:00:01    1.2345
    01-01-2015 00:00:15    3.1415

but unless formatting is changed in Base before copying, "Copy" will only copy the timestamp to the format chosen for SHOWING the data in the database: Time to the level of full minutes, numbers with two decimal places.

Whether this behaviour (copying truncating to the shown precision) is a bug or a feature depends on the viewpoint - or put another way, the current behaviour has both advantages and disadvantages:

Advantages: Copying a full table can mean copying a huge amount of data to the clipboard. And copying data with full precision can give a confusing result on insert in e.g. a text file.

Disadvantages: The user is not warned that "Copy" is a lossy copy. The behaviour is different from "Copy" in Calc, where data is copied in full precision regardless of formatting for showing. Finally, alternatives for copying with full precision may not be obvious to the user.

A solution to make everybody happy may be to have two versions of copy:

a) Rename the current behaviour to "Copy as shown". This makes it clear to the user that there may be data loss.

b) Implement copy to retain full precision. This can be called "Copy" or perhaps "Copy with full precision". This allows users like me to retain the full precision of the data when copying.

Best regards,
Lars
Comment 1 Alex Thurgood 2017-08-25 13:09:58 UTC
In the test file provided the field MyDouble is defined without any decimal places, and the values entered show up as 1.23 and 3.14 - is this what you intended ?

Testing on 

Version: 5.4.0.3
Build ID: 7556cbc6811c9d992f4064ab9287069087d7f62c
CPU threads: 4; OS: Mac OS X 10.12.6; UI render: default; 
Locale: fr-FR (fr_FR.UTF-8); Calc: group
Comment 2 Alex Thurgood 2017-08-25 13:11:21 UTC
Additionally, the timestamp field definition formatting is given as :

DD-MM-YY TT:MM

Is this also what you intended ?
Comment 3 Alex Thurgood 2017-08-25 13:35:58 UTC
Seems like bug 67763 is also relevant here.
Comment 4 Robert Großkopf 2017-08-26 08:36:17 UTC
(In reply to Alex Thurgood from comment #1)
> In the test file provided the field MyDouble is defined without any decimal
> places, and the values entered show up as 1.23 and 3.14 - is this what you
> intended ?

Double could be 15 digits. There must not be defined any decimal-places. The field will save something like
1.2345678901234
and also
123456789.12345

The problem described by  Lars Jødal is: The database will save all this (you could see this in the table-GUI when setting, for example, "MyDouble" to show 4 decimal-places), but data will only be copied with the precision you define in table-GUI, not which is defined for the database. 

Note: the decimal-places won't be shown when copying the data through clipboard by Ctrl+C, but it will appear wen copying data by drag and drop into Calc. The same with the timestamp.
Comment 5 Lars Jødal 2017-08-28 16:57:07 UTC
(In reply to robert from comment #4)
> (In reply to Alex Thurgood from comment #1)
> > In the test file provided the field MyDouble is defined without any decimal
> > places, and the values entered show up as 1.23 and 3.14 - is this what you
> > intended ?
> 
> Double could be 15 digits. There must not be defined any decimal-places. The
> field will save something like
> 1.2345678901234
> and also
> 123456789.12345
> 
> The problem described by  Lars Jødal is: The database will save all this
> (you could see this in the table-GUI when setting, for example, "MyDouble"
> to show 4 decimal-places), but data will only be copied with the precision
> you define in table-GUI, not which is defined for the database. 

Yes, this was my point. (So yes, it was intended to define the format to show less precision that is contained in the data.)

> Note: the decimal-places won't be shown when copying the data through
> clipboard by Ctrl+C, but it will appear wen copying data by drag and drop
> into Calc. The same with the timestamp.

Fine, drag-and-drop is one way to copy with full precision. But it may not be obvious to the user that Ctrl+C can be lossy (it took me some time to realize it).

Is the issue clear enough to change status from "NEEDINFO"?

If yes, what does people think of my suggestions to remedy the issue?

Best regards
Lars
Comment 6 Robert Großkopf 2017-08-28 19:06:03 UTC
I have set this bug to NEW, because the bug appears when copying a table through clipboard. Don't know why there is a difference between copy/paste and drag and drop - but drag and drop will show the precision of the real data, not only the data, which is been shown in the table.
Comment 7 QA Administrators 2018-08-29 02:41:37 UTC Comment hidden (obsolete)
Comment 8 Alex Thurgood 2018-08-29 07:30:04 UTC
This is still reproducible in 

Version: 6.0.5.2
Build ID: 54c8cbb85f300ac59db32fe8a675ff7683cd5a16
Threads CPU : 8; OS : Mac OS X 10.13.6; UI Render : par défaut; 
Locale : fr-FR (fr_FR.UTF-8); Calc: group
Comment 9 Alex Thurgood 2018-08-29 07:31:49 UTC
Also reproducible in 

Version: 6.1.0.0.alpha0+
Build ID: b9955b2083ffdc1f99bc8be6b09d806fa3279a16
CPU threads: 8; OS: Mac OS X 10.13.6; UI render: default; 
Locale: fr-FR (fr_FR.UTF-8); Calc: group
Comment 10 Lars Jødal 2019-07-15 10:51:20 UTC
Still reproducible in:

Version: 6.2.5.2 (x64)
Build ID: 1ec314fa52f458adc18c4f025c545a4e8b22c159
CPU threads: 4; OS: Windows 10.0; UI render: GL; VCL: win; 
Locale: da-DK (da_DK); UI-Language: en-GB
Calc: threaded

Also reproducible in:

Version: 6.3.0.1 (x64)
Build ID: 41ac97386aba908b6db860cfb4cfe2da871886ae
CPU tråde: 4; Styresystem: Windows 10.0; Gengiver af brugergrænseflade: GL; VCL: win; 
Lokalisering: da-DK (da_DK); UI-Language: da-DK
Calc: threaded
Comment 11 QA Administrators 2021-09-19 03:43:06 UTC Comment hidden (obsolete)
Comment 12 Lars Jødal 2021-12-28 07:05:41 UTC
Still reproducible in

Version: 7.2.4.1 (x64) / LibreOffice Community
Build ID: 27d75539669ac387bb498e35313b970b7fe9c4f9
CPU threads: 8; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: da-DK (da_DK); UI: da-DK
Calc: CL
Comment 13 QA Administrators 2023-12-29 03:11:48 UTC Comment hidden (obsolete)
Comment 14 Lars Jødal 2023-12-29 06:11:15 UTC
Still reproducible in

Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: da-DK (da_DK); UI: da-DK
Calc: threaded

As before, "Copy" copies only with the precision shown on the screen, while drag & drop (correctly) retains the full precision.