mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-21 16:31:56 +01:00
Hack to support building with Cabal >=3.4
It remains to be seen if this has any user-visible change. Hopefully not, but even if it does, it shouldn't cause any breakage: ">=0" is forward and backward-compatible.
This commit is contained in:
parent
5cb5668295
commit
9f7d079cfe
20
src/Types.hs
20
src/Types.hs
@ -407,7 +407,25 @@ instance ToMarkup VersionRangeP where
|
|||||||
instance PersistField VersionRangeP where
|
instance PersistField VersionRangeP where
|
||||||
toPersistValue = PersistText . textDisplay
|
toPersistValue = PersistText . textDisplay
|
||||||
fromPersistValue v =
|
fromPersistValue v =
|
||||||
fromPersistValue v >>= bimap (T.pack . displayException) VersionRangeP . dtParse
|
fromPersistValue v >>= bimap (T.pack . displayException) VersionRangeP . dtParse . hackwardCompat_3_4
|
||||||
|
where
|
||||||
|
-- We use parseSimple under the hood, which always parses using
|
||||||
|
-- the latest version of the Cabal spec. In practice, this hasn't
|
||||||
|
-- been a problem. Until now.
|
||||||
|
--
|
||||||
|
-- Cabal spec 3.4 dropped support for "-any" as a version range, and the
|
||||||
|
-- database is full of such values. Luckily, ">=0" is a
|
||||||
|
-- backward-compatible synonym for "-any". New versions of this app will
|
||||||
|
-- write ">=0" instead of "-any", which old versions of this app will
|
||||||
|
-- understand just fine. We just need to substitute on read.
|
||||||
|
--
|
||||||
|
-- FIXME: strictly speaking, VersionRange cannot be parsed without
|
||||||
|
-- knowing the Cabal spec version of the package that used it. There's
|
||||||
|
-- nothing *wrong* with "-any". That means we probably need to decode it
|
||||||
|
-- no further than Text and do further processing outside of the
|
||||||
|
-- PersistField instance.
|
||||||
|
hackwardCompat_3_4 "-any" = ">=0"
|
||||||
|
hackwardCompat_3_4 t = t
|
||||||
instance PersistFieldSql VersionRangeP where
|
instance PersistFieldSql VersionRangeP where
|
||||||
sqlType _ = SqlString
|
sqlType _ = SqlString
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user