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:
- 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
- Use views
- In C++:
- Use
isNull() to check values for NULL before setting the value
- Use a custom QVariant toInt()/toDouble() function that return -1 for NULL values
Not sure what the best-performing solution is, probably SQL views