Right now, the only working way to convert a double precision value you know the unit of into a value of the type unit is concat(23.5, '°C')::unit which is a bit clunky.
I tried 23.5 * '°C'::unit but this does not work with units with offsets (such as celsius) as this would return the incorrect amount 23.5 K.
I'd imagine a function like at_unit(double precision, unit) which might be able to do the job more efficiently instead of converting a double to string and back again.
Right now, the only working way to convert a
double precisionvalue you know the unit of into a value of the typeunitisconcat(23.5, '°C')::unitwhich is a bit clunky.I tried
23.5 * '°C'::unitbut this does not work with units with offsets (such as celsius) as this would return the incorrect amount23.5 K.I'd imagine a function like
at_unit(double precision, unit)which might be able to do the job more efficiently instead of converting a double to string and back again.