Skip to content

ld-tools / SQLite: NULL values from database are imported as 0 instead of -1 #987

@Stefan-Olt

Description

@Stefan-Olt

This issue came with the transition from JSON to SQLite for metadata storage:
The default values are -1 in the structs for the metadata (with the meaning of not set). In a SQLite table NULL has the meaning of not set, but when reading the data from the database NULL values are read as 0 and not -1.
This problem is very obvious when trying to export the metadata, as all fields are now considered set and written with the value 0.

Possible solutions:

  • In SQL:
    1. Use a SQL-function like this:
    SELECT field_id, COALESCE(w_snr, -1.0) AS w_snr, COALESCE(b_psnr, -1.0) AS b_psnr FROM vits_metrics
    1. Use views
  • In C++:
    1. Use isNull() to check values for NULL before setting the value
    2. Use a custom QVariant toInt()/toDouble() function that return -1 for NULL values

Not sure what the best-performing solution is, probably SQL views

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions