-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for decimal types other than Foundation.Decimal #377
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #377 +/- ##
==========================================
- Coverage 61.82% 61.72% -0.11%
==========================================
Files 125 126 +1
Lines 10019 10024 +5
==========================================
- Hits 6194 6187 -7
- Misses 3825 3837 +12
|
It feels to me like this could be accomplished without a new protocol by making |
My gut feel is that as long as |
bf7ea47
to
3eab477
Compare
Currently, the only numerical option for an exact representation of the Postgres NUMERIC type is to use
Foundation.Decimal
. However,Foundation.Decimal
is not fully implemented, and in particular is missing some useful conformances such asLosslessStringConvertible
orFloatingPoint
. The current implementation makes it complex to use other Decimal implementations to map to the NUMERIC type.This PR aims to provide a new protocol
ExpressibleByFloatingPointString
, to whichFoundation.Decimal
can trivially conform, and at the same time allow to easily make other Decimal types conform to (*), and be used as mapping to the Postgres NUMERIC type.The change aims to make no changes to the API. It has been tested with the Test suite from postgres-nio and that of postgres-kit as well as from use in a higher level Vapor app.
--
(*) for example
BigDecimal
from https://github.com/mgriebling/BigDecimal.git