SQLpage icon indicating copy to clipboard operation
SQLpage copied to clipboard

PostgreSQL money values are not displayed when a query contains variables

Open rhysparry opened this issue 4 months ago • 3 comments

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):

Actual: 0.0

Expected (from 0.35.1):

Expected: $1.23

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

rhysparry avatar Aug 02 '25 23:08 rhysparry

Hi! Thanks for the quick report. This will be fixed in v0.36.1

lovasoa avatar Aug 03 '25 17:08 lovasoa

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.

lovasoa avatar Aug 03 '25 22:08 lovasoa

Reopening with a new title to reflect how the bug occurs even in 0.36.1 when queries contain parameters

lovasoa avatar Aug 03 '25 22:08 lovasoa