Open NorfairKing opened 2 months ago
MySQL have BIGINT UNSIGNED
(unsigned 64bit integer)
PostgreSQL have numeric
(user-specified precision, exact)
Related issue: #1095 And a potential fix #1096
I agree this is really unfortunate. I think we'd need to remove the instance for Word64
for a release (or two) and provide LegacyWord64
and ProperWord64
newtypes to make this a migration that wouldn't cause data integrity issues for folks relying on the existing behavior.
Bug Reports
The
Word64
instance forPersistField
does not roundtrip through databases correctly. It usesfromIntegral
for converting betweenWord64
andInt64
.While this does technically roundtrip, the database values will be silently wrong because negative values will be saved instead of positive ones.
Example:
This does technically roundtrip:
BUT the database will contain
-1
, which does not sort in the same way.Solutions
You could have another
PersistValue
constructor forWord64
, but I'm not sure if all the "supported" databases support such a type. As far as I can tell,sqlite
supports larger integers by storing them asreal
s but I don't know about other databases: