Open ratranqu opened 1 year ago
Attention: Patch coverage is 70.00000%
with 9 lines
in your changes are missing coverage. Please review.
Project coverage is 61.72%. Comparing base (
dc9caf8
) to head (3eab477
).
It feels to me like this could be accomplished without a new protocol by making PostgresNumeric
(which is already public) directly PostgresCodable
; non-Foundation decimal types would then be able to more easily conform to PostgresCodable
themselves using it. But I could easily be missing something. @fabianfett, any thoughts?
It feels to me like this could be accomplished without a new protocol by making
PostgresNumeric
(which is already public) directlyPostgresCodable
; non-Foundation decimal types would then be able to more easily conform toPostgresCodable
themselves using it. But I could easily be missing something. @fabianfett, any thoughts?
My gut feel is that as long as PostgresNumeric
(an exact type) allows itself to be represented on the Swift side by Float
s or Double
s (non exact) as well as Decimal
/exact types, it will be difficult to allow for that since Float
/Double
have their own PostgresCodable
specificities?
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