Bug 352363 - Broken floating-point constants in queries
Summary: Broken floating-point constants in queries
Status: CLOSED FIXED
Alias: None
Product: KEXI
Classification: Applications
Component: Queries (show other bugs)
Version: 2.9.7
Platform: Other Linux
: NOR normal
Target Milestone: 2.9.8
Assignee: Jarosław Staniek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-06 20:29 UTC by Jarosław Staniek
Modified: 2015-11-30 08:12 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.9.8
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jarosław Staniek 2015-09-06 20:29:52 UTC
Floating-point constants are not correctly parser in the SQL view of the Kexi query designer.
Fractional part is parser as integer without remembering the leading zeros.

Example:
- 1.2 is parsed as a pair of integers: (1, 2). This is OK.
- 1.002 is parsed as a pair of integers: (1, 2). This is not OK since the value decoded back to floating point is: 1.2.


Reproducible: Always

Steps to Reproduce:
1. Open a new query design and type "SELECT 1.002" in the SQL view
2. Go to the data view

Actual Results:  
1.2 is displayed

Expected Results:  
1.002 is displayed

A workaround for Kexi <= 2.9.7 is: use the following notation e.g. for 1.002 constant: 1002/1000.

The bug is driver-independent.
Comment 1 Jarosław Staniek 2015-09-06 20:41:21 UTC
Extra info:
- when user goes back to the SQL view, 1.2 is displayed, so the original constant is lost
- changes are not saves unless user saves the query design though
- the bug is apparently present since the beginning: Kexi 0.1 beta
Comment 2 Jarosław Staniek 2015-09-12 22:26:21 UTC
Git commit 4b9456f7f0741c8510015e9996929220eea4410e by Jaroslaw Staniek.
Committed on 12/09/2015 at 20:45.
Pushed by staniek into branch 'kexi-functions-352631-staniek'.

Fix broken floating-point constants in Kexi SQL queries

Summary:
Bonus: After parsing numbers are now kept losslessly as byte arrays, so with unlimited precision.
FIXED-IN:2.9.8

Test Plan: See "Steps to Reproduce" at https://bugs.kde.org/show_bug.cgi?id=352363

Reviewers: piggz

Subscribers: Kexi-Devel-list

Differential Revision: https://phabricator.kde.org/D333

M  +1    -1    libs/db/expression.cpp
M  +52   -51   libs/db/parser/sqlparser.cpp
M  +1    -1    libs/db/parser/sqlparser.h
M  +5    -4    libs/db/parser/sqlparser.y
M  +54   -72   libs/db/parser/sqlscanner.cpp
M  +3    -22   libs/db/parser/sqlscanner.l

http://commits.kde.org/calligra/4b9456f7f0741c8510015e9996929220eea4410e
Comment 3 Jarosław Staniek 2015-11-30 08:11:28 UTC
Git commit 79d5e7c5af55cb4152b7b2b59f8d457961f051be by Jaroslaw Staniek.
Committed on 30/11/2015 at 08:07.
Pushed by staniek into branch 'master'.

Fix broken floating-point constants in SQL queries

Bonus: After parsing numbers are now kept losslessly as byte arrays, so with unlimited precision.

Test Plan: See "Steps to Reproduce" at https://bugs.kde.org/show_bug.cgi?id=352363

>From calligradb 2.9 4b9456f7f0741c

M  +5    -5    autotests/ExpressionsTest.cpp
M  +2    -9    src/expression/KDbConstExpression.cpp
M  +5    -4    src/parser/KDbSqlParser.y
M  +3    -22   src/parser/KDbSqlScanner.l
M  +53   -52   src/parser/generated/sqlparser.cpp
M  +1    -1    src/parser/generated/sqlparser.h
M  +56   -74   src/parser/generated/sqlscanner.cpp

http://commits.kde.org/kdb/79d5e7c5af55cb4152b7b2b59f8d457961f051be