yesodweb / yesodweb/persistent
DB representation for `Word64` values greater than `maxBound :: Int64` are negative
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
Defining a column as Word64 and writing a value in the range [maxBoundInt64 +1 .. maxBoundWord64] results in a negative value (ie the Int64 bit pattern of the Word64) being inserted into the database.
The reason for this is that the Word64 type in the schema definition is converted to SqlInt64 which is then written to the database. The reverse is done when read the value is read, so the value is correct in Haskell land but the value in the database is negative. This is a problem for interop when the database is used from languages other then Haskell.
The obvious solution is to add an SqlWord64 constructor to the type to SqlType.
@parsonsmatt Is this a sane idea? Volunteering to do this if it is.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the SqlType definition and the Word64-to-SqlInt64 conversion path described in the issue. Trace the corresponding read and write paths across the persistence backends; done means large Word64 values are stored with a database representation suitable for interoperability while still round-tripping correctly in Haskell.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100