Conversation
Previously when the schema used `Word64` as the column type, Persistent would use `SqlInt64` as the SQL representation which means that `Word64` values above `maxBound :: Int64` would be stored as negative values in the database. That is fine for a database only accessed from Haskell but is a pain in the neck when the database is used as an interop layer for other languages. This commit fixes these issues by adding `SqlWord64` and `PersistWord64`. Closes: yesodweb#1095
|
@parsonsmatt Once I fix all the CI errors is there anything else required to get this merged? |
|
I'm going to be out for the next week so you may want to ping another maintainer if you want it in soon :) I generally trust your judgement and I don't expect there will be any issues aside from the checklist. |
|
Currently getting the following failure in CI: I am not even sure which database backend this is coming from. However Clues? |
|
How does one run the tests? I use Postgres and was trying There is a shell script at |
parsonsmatt
left a comment
There was a problem hiding this comment.
I think the testing setup relied on older behavior of postgres authentication. It should probably require a specific user and a password.
|
|
||
| instance PersistField Word64 where | ||
| toPersistValue = PersistInt64 . fromIntegral | ||
| toPersistValue = PersistWord64 . fromIntegral |
There was a problem hiding this comment.
is fromIntegral here a no-op?
| | SqlTime | ||
| | SqlDayTime -- ^ Always uses UTC timezone | ||
| | SqlBlob | ||
| | SqlWord64 -- @since 2.11.0 |
There was a problem hiding this comment.
| | SqlWord64 -- @since 2.11.0 | |
| | SqlWord64 -- ^ @since 2.11.0 |
so it is a proper doc comment
| data PersistValue = PersistText Text | ||
| | PersistByteString ByteString | ||
| | PersistInt64 Int64 | ||
| | PersistWord64 Word64 -- @since 2.11.0 |
There was a problem hiding this comment.
| | PersistWord64 Word64 -- @since 2.11.0 | |
| | PersistWord64 Word64 -- ^ @since 2.11.0 |
| showSqlType SqlString = "VARCHAR" | ||
| showSqlType SqlInt32 = "INTEGER" | ||
| showSqlType SqlInt64 = "INTEGER" | ||
| showSqlType SqlWord64 = "INTEGER" |
There was a problem hiding this comment.
I wonder if this is what's going on with the failing test you're finding. Based on this saying that INTEGER is (at most) an 8 byte size, I'd expect that maxBound :: Word64 would be troublesome.
There was a problem hiding this comment.
Which, uh. Hm. Would suggest that the current behavior is Correct, since the test isn't failing right now, at least for SQLite.
|
@erikd So in my investigation on this problem, it looks like there isn't going to be a way to get SQLite to have the "proper" behavior - the |
Previously when the schema used
Word64as the column type, Persistentwould would use
SqlInt64as the SQL representation which means thatWord64values abovemaxBound :: Int64would be stored as negativevalues in the database. That is fine for a database only accessed from
Haskell but is a pain in the neck when the database is used as an
interop layer for other languages.
This commit fixes these issues by adding
SqlWord64andPersistWord64.Closes: #1095
This works in my application. Specifically it fixes IntersectMBO/cardano-db-sync#163 but has not been tested beyond that. I have not fixed or even tested this for the other database back ends. I will see what CI says.
@sincedeclarations to the HaddockAfter submitting your PR:
(unreleased)on the Changelog