PostgreSQL money values are not displayed when a query contains variables
Introduction
After upgrading to SQLPage 0.36.0, money values from PostgreSQL now all show 0.0 as the value. This worked in version 0.35.0.
To Reproduce
With a PostgreSQL database configured, use the following SQL query:
select 'big_number' as component;
select 1.23::money as value,
'Value' as title,
'Money value' as description
;
Actual behavior
Value shows as 0.0
The following error is shown in the logs:
sqlpage::webserver::database::sql_to_json] Failed to decode f64 value: invalid float literal
Screenshots
Actual (0.36.0):
Expected (from 0.35.1):
Expected behavior
The value will be displayed correctly with the currency symbol (as per version 0.35.1)
Version information
- OS: macOS
- Database PostgreSQL
- SQLPage Version: 0.36.0
Hi! Thanks for the quick report. This will be fixed in v0.36.1
Hi @rhysparry !
Looking at this in a little more details, the issue is similar to https://github.com/sqlpage/SQLPage/issues/721#issuecomment-3044928023
Postgres returns
- textual money representations for static queries (so we can display "$1.23"),
- and binary values for parametrized queries (so it transmits only the number 123, without the decimal point and the currency)
so the previous behavior will be reintroduced, making your dashboard work again as long as you keep all your queries fully static. But I'd still recommend manually casting to text on the database side to ensure consistent results, even if you later introduce parameters to your queries:
select my_money_column::text as value,
'Value' as title,
'Money value' as description
;
I'll keep this issue opened.
Reopening with a new title to reflect how the bug occurs even in 0.36.1 when queries contain parameters