postgresql 10's numeric data type maps to xxx in c# golang rust drivers??

From: john snow <ofbizfanster(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: postgresql 10's numeric data type maps to xxx in c# golang rust drivers??
Date: 2017-12-27 11:14:04
Message-ID: CAE67tvWVoF0Mo9cK4S4QcoxFTEr7ViBWTgS6OVo7kqqMC73gmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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!

Browse pgsql-novice by date

  From Date Subject
Next Message Mike 2017-12-27 18:53:01 LibreOffice Base Connect to postgresql
Previous Message Tom Lane 2017-12-23 16:31:13 Re: Unexpected behavior with inherited constraints