packages feed

persistent 0.8.0 → 0.8.0.1

raw patch · 3 files changed

+83/−6 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Database/Persist/Store.hs view
@@ -60,10 +60,10 @@ import Data.Typeable (Typeable) import Data.Int (Int8, Int16, Int32, Int64) import Data.Word (Word8, Word16, Word32, Word64)-import Text.Blaze (Html, unsafeByteString)-import Text.Blaze.Renderer.Utf8 (renderHtml)+import Text.Blaze (Html, preEscapedText)+import Text.Blaze.Renderer.Text (renderHtml) import qualified Data.Text as T-import qualified Data.ByteString as S+import qualified Data.Text.Lazy as TL import qualified Data.ByteString.Lazy as L import qualified Control.Monad.IO.Class as Trans @@ -247,8 +247,8 @@     sqlType _ = SqlString  instance PersistField Html where-    toPersistValue = PersistByteString . S.concat . L.toChunks . renderHtml-    fromPersistValue = fmap unsafeByteString . fromPersistValue+    toPersistValue = PersistText . TL.toStrict . renderHtml+    fromPersistValue = fmap preEscapedText . fromPersistValue     sqlType _ = SqlString  instance PersistField Int where
persistent.cabal view
@@ -1,5 +1,5 @@ name:            persistent-version:         0.8.0+version:         0.8.0.1 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>
+ test/main.hs view
@@ -0,0 +1,77 @@+{-# LANGUAGE OverloadedStrings #-}+import Test.Hspec.Monadic+import Test.Hspec.HUnit ()+import Test.HUnit++import Database.Persist.Quasi+import Database.Persist.EntityDef++main :: IO ()+main = hspecX $ do+    describe "tokenization" $ do+        it "handles normal words" $+            tokenize " foo   bar  baz" @?=+                [ Spaces 1+                , Token "foo"+                , Spaces 3+                , Token "bar"+                , Spaces 2+                , Token "baz"+                ]+        it "handles quotes" $+            tokenize "  \"foo bar\"  \"baz\"" @?=+                [ Spaces 2+                , Token "foo bar"+                , Spaces 2+                , Token "baz"+                ]+        it "handles unnested parantheses" $+            tokenize "  (foo bar)  (baz)" @?=+                [ Spaces 2+                , Token "foo bar"+                , Spaces 2+                , Token "baz"+                ]+        it "handles nested parantheses" $+            tokenize "  (foo (bar))  (baz)" @?=+                [ Spaces 2+                , Token "foo (bar)"+                , Spaces 2+                , Token "baz"+                ]+        it "escaping " $+            tokenize "  (foo \\(bar)  \"baz\\\"\"" @?=+                [ Spaces 2+                , Token "foo (bar"+                , Spaces 2+                , Token "baz\""+                ]+    describe "parseFieldType" $ do+        it "simple types" $+            parseFieldType "FooBar" @?= Just (FTTypeCon Nothing "FooBar")+        it "module types" $+            parseFieldType "Data.Map.FooBar" @?= Just (FTTypeCon (Just "Data.Map") "FooBar")+        it "application" $+            parseFieldType "Foo Bar" @?= Just (+                FTTypeCon Nothing "Foo" `FTApp` FTTypeCon Nothing "Bar")+        it "application multiple" $+            parseFieldType "Foo Bar Baz" @?= Just (+                (FTTypeCon Nothing "Foo" `FTApp` FTTypeCon Nothing "Bar")+                `FTApp` FTTypeCon Nothing "Baz"+                )+        it "parens" $ do+            let foo = FTTypeCon Nothing "Foo"+                bar = FTTypeCon Nothing "Bar"+                baz = FTTypeCon Nothing "Baz"+            parseFieldType "Foo (Bar Baz)" @?= Just (+                foo `FTApp` (bar `FTApp` baz))+        it "lists" $ do+            let foo = FTTypeCon Nothing "Foo"+                bar = FTTypeCon Nothing "Bar"+                bars = FTList bar+                baz = FTTypeCon Nothing "Baz"+            parseFieldType "Foo [Bar] Baz" @?= Just (+                foo `FTApp` bars `FTApp` baz)+    describe "stripId" $ do+        it "works" $+            (parseFieldType "FooId" >>= stripId) @?= Just "Foo"