dbgate / dbgate

Database manager for MySQL, PostgreSQL, SQL Server, MongoDB, SQLite and others. Runs under Windows, Linux, Mac or as web application
https://dbgate.org
GNU General Public License v3.0
4.75k stars 279 forks source link

BUG: Special floating point values (Infinity and NaN) are shown as null #818

Open pgp opened 3 weeks ago

pgp commented 3 weeks ago

Describe the bug DbGate shows Infinity and NaN floating point values as NULL, both when they are scalar, and when they are in a (multidimensional) array type.

To Reproduce Steps to reproduce the behavior:

  1. Launch the following queries to create and populate an example table:
    
    CREATE TABLE example(
    id SERIAL PRIMARY KEY,
    scalar1 float8 not null,
    scalar2 float8 not null,
    scalar3 float8 not null,
    arr1 float4[][] not null,
    arr2 float8[][] not null
    );

INSERT INTO example(scalar1, scalar2, scalar3, arr1, arr2) VALUES ( 'Infinity'::float8, -'Infinity'::float8, 'NaN'::float8, ARRAY[['Infinity'::float4, 1.0, 2.0], [3.0, -'Infinity'::float4, 4.0], [5.0, 6.0, 'NaN'::float4]], ARRAY[['Infinity'::float8, 1.1, 2.1], [3.1, -'Infinity'::float8, 4.1], [5.1, 6.1, 'NaN'::float8]] );



2. Infinity and NaN values are shown as NULL, as shown in the following screenshots:
![immagine](https://github.com/dbgate/dbgate/assets/754079/572d98b1-ffe8-4bf2-ad4c-50e4185e11d6)
![immagine](https://github.com/dbgate/dbgate/assets/754079/aad94058-58eb-4bff-865d-bdc8a384a052)
![immagine](https://github.com/dbgate/dbgate/assets/754079/5f13cb72-ffa4-421e-a75c-1cbed099bfc9)

3. Even when performing a Copy Without Headers command, values are shown as NULL

4. SQL Generator for INSERT statements partially works (special values are correctly shown, but only if they are in scalar fields, not in arrays):
![sqlgen](https://github.com/dbgate/dbgate/assets/754079/f8887dc3-ceb3-4e70-9853-2f07e66b4cc2)

5. Other clients (e.g. DBeaver and pgAdmin) correctly show special values:
![immagine](https://github.com/dbgate/dbgate/assets/754079/63480f9e-5761-4e12-9b30-44ea1f9d9c84)
![image_2024_06_04T09_33_14_153Z_20240604_114040810](https://github.com/dbgate/dbgate/assets/754079/12d78c1b-736b-40f4-a7fe-1732367ad358)

**Version Information:**
 - OS: Manjaro Linux x64
 - App Version: 5.2.10-beta.4 (Linux x64 AppImage)
 - Database engine: PostgreSQL 16.2