Bug 42400 - Query designer: numeric literal in condition on (VAR)CHAR column destructively transformed into string
Summary: Query designer: numeric literal in condition on (VAR)CHAR column destructivel...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
3.4.3 release
Hardware: All All
: low minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Database-Queries
  Show dependency treegraph
 
Reported: 2011-10-30 06:57 UTC by Lionel Elie Mamane
Modified: 2018-10-19 19:38 UTC (History)
3 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 Lionel Elie Mamane 2011-10-30 06:57:31 UTC
Reproduced on 3.4.3 and master (3.5)

Open the following SQL query in the query designer:

  SELECT col FROM tbl WHERE col = 8

where "col" is a VARCHAR column of table tbl. It is specific to the db system whether this query is valid... E.g. in PostgreSQL it is not (error), but in MySQL it is perfectly valid: a maximal prefix of col is converted to a number and compared to 8.

Switch to design view.

The "Condition" row of the "col" column shows "8" (without the double quotes). Switch back to SQL view. The query looks like:

  SELECT col FROM tbl WHERE col = '8'

Switch back to design view, the "condition" row now reads "'8'" (without the double quotes, with the single quotes).

The query was changed, and does not give the same result anymore... In MySQL instead of returning col values "'8'", "'8 children'", ... it returns only col value "'8'".

Slightly worse, now consider:

  SELECT col FROM tbl WHERE col = 8.5

If one is in a locale where the decimal separator is "," (comma), the query designer changes that to

  SELECT col FROM tbl WHERE col = '8,5'

The dot becomes a comma, leading to a (very minor) data loss: without a copy of the original query, it is not obvious whether the original query contained 8.5 or 8,5.


Just for complete clarity: I think it is good that if the user types "8" into the query designer, it gets automatically converted to "'8'"; that's most probably what he/she meant. This is about not changing the meaning of an existing (working) query.
Comment 1 sasha.libreoffice 2012-08-07 10:54:54 UTC
in 3.5.5 on Fedora 64 bit, internal hsqldb:
> SELECT col FROM tbl WHERE col = 8
no problem found
> SELECT col FROM tbl WHERE col = 8.5
Switching from SQL view to design view results in 8,5. Switching to SQL view results in message "SQL syntax error".
Comment 2 Alex Thurgood 2015-01-03 17:38:15 UTC Comment hidden (no-value)
Comment 3 QA Administrators 2016-01-17 20:02:19 UTC Comment hidden (obsolete)
Comment 4 QA Administrators 2017-03-06 13:52:39 UTC
** Please read this message in its entirety before responding **

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present on a currently supported version of LibreOffice 
(5.2.5 or 5.3.0  https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the version of LibreOffice and 
your operating system, and any changes you see in the bug behavior
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave 
a short comment that includes your version of LibreOffice and Operating System

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3)

http://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to "inherited from OOo";
4b. If the bug was not present in 3.3 - add "regression" to keyword


Feel free to come ask questions or to say hello in our QA chat: http://webchat.freenode.net/?channels=libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug-20170306