Discussion:
postgresql 10's numeric data type maps to xxx in c# golang rust drivers??
john snow
2017-12-27 11:14:04 UTC
Permalink
we're using postgresql 10 in a windows environment.

in a c# dotnet environment we're using Npgsql as the driver, and the
numeric type
maps to a c# decimal (128bit) type, which is what we want because we are
using numeric to represent currency (usd$ and other foreign currency types)
/ money data.

we're also planning to use google's go and mozilla's rust for some
applications.

our questions:

(1) unlike Npgsql documentation, which explicitly calls out the mapping of
numeric to decimal (see http://www.npgsql.org/doc/types/basic.html), the
documentation for the go drivers (https://github.com/jackc/pgx,
https://godoc.org/github.com/lib/pq) and rust driver (
https://github.com/sfackler/rust-postgres) we've looked at don't explicitly
call out such a mapping. is it correct to assume that numeric maps to
float64 in go and rust?

(2) is postgresql's numeric data type the correct one for representing
money / currency values?

(3) if numeric maps to float64 in go and rust, how concerned should we be
regarding (accumulative) rounding errors? should we just use bigint in
postgresql and int64 in c# go and rust and accept some increase in
application code complexity (e.g., converting cents to dollars and vice
versa, etc)?

(4) any other suggestion?

thanks for helping!

Loading...