packages feed

persistent 2.2.2.1 → 2.2.3

raw patch · 4 files changed

+32/−4 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,3 +1,12 @@+## 2.2.3++* PersistField instance for Natural+* better oracle support in odbc++## 2.2.2++* Add liftSqlPersistMPool function+ ## 2.2.1  * Migration failure message with context
Database/Persist/Class/PersistField.hs view
@@ -55,6 +55,10 @@ import System.Locale (defaultTimeLocale) #endif +#if MIN_VERSION_base(4,8,0)+import Numeric.Natural (Natural)+#endif+ -- | A value which can be marshalled to and from a 'PersistValue'. class PersistField a where     toPersistValue :: a -> PersistValue@@ -189,7 +193,7 @@     [(a, "")] -> Right $ toRational (a :: Pico)     _ -> Left $ "Can not read " <> t <> " as Rational (Pico in fact)"   fromPersistValue (PersistInt64 i) = Right $ fromIntegral i-  fromPersistValue (PersistByteString bs) = case double $ T.cons '0' $ T.decodeUtf8With T.lenientDecode bs of +  fromPersistValue (PersistByteString bs) = case double $ T.cons '0' $ T.decodeUtf8With T.lenientDecode bs of                                               Right (ret,"") -> Right $ toRational ret                                               Right (a,b) -> Left $ "Invalid bytestring[" <> T.pack (show bs) <> "]: expected a double but returned " <> T.pack (show (a,b))                                               Left xs -> Left $ "Invalid bytestring[" <> T.pack (show bs) <> "]: expected a double but returned " <> T.pack (show xs)@@ -199,7 +203,7 @@     toPersistValue = PersistBool     fromPersistValue (PersistBool b) = Right b     fromPersistValue (PersistInt64 i) = Right $ i /= 0-    fromPersistValue (PersistByteString i) = case readInt i of +    fromPersistValue (PersistByteString i) = case readInt i of                                                Just (0,"") -> Right False                                                Just (1,"") -> Right True                                                xs -> error $ "PersistField Bool failed parsing PersistByteString xs["++show xs++"] i["++show i++"]"@@ -254,6 +258,12 @@      fromPersistValue x = Left $ T.pack $ "Expected UTCTime, received: " ++ show x +#if MIN_VERSION_base(4,8,0)+instance PersistField Natural where+  toPersistValue = (toPersistValue :: Int64 -> PersistValue) . fromIntegral+  fromPersistValue x = fromIntegral <$> (fromPersistValue x :: Either Text Int64)+#endif+ instance PersistField a => PersistField (Maybe a) where     toPersistValue Nothing = PersistNull     toPersistValue (Just a) = toPersistValue a@@ -342,7 +352,7 @@     fromPersistValue PersistNull         = Right Inactive     fromPersistValue (PersistBool True)  = Right Active     fromPersistValue (PersistInt64 1)    = Right Active-    fromPersistValue (PersistByteString i) = case readInt i of +    fromPersistValue (PersistByteString i) = case readInt i of                                                Just (0,"") -> Left $ T.pack "PersistField Checkmark: found unexpected 0 value"                                                Just (1,"") -> Right Active                                                xs -> Left $ T.pack $ "PersistField Checkmark failed parsing PersistByteString xs["++show xs++"] i["++show i++"]"
Database/Persist/Sql/Class.hs view
@@ -34,6 +34,10 @@ import Data.Bits (bitSize) import qualified Data.Vector as V +#if MIN_VERSION_base(4,8,0)+import Numeric.Natural (Natural)+#endif+ -- | Class for data types that may be retrived from a 'rawSql' -- query. class RawSql a where@@ -273,6 +277,11 @@         _mn = return n `asTypeOf` a instance PersistFieldSql Rational where     sqlType _ = SqlNumeric 32 20   --  need to make this field big enough to handle Rational to Mumber string conversion for ODBC++#if MIN_VERSION_base(4,8,0)+instance PersistFieldSql Natural where+  sqlType _ = SqlInt64+#endif  -- An embedded Entity instance (PersistField record, PersistEntity record) => PersistFieldSql (Entity record) where
persistent.cabal view
@@ -1,5 +1,5 @@ name:            persistent-version:         2.2.2.1+version:         2.2.3 license:         MIT license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>