packages feed

persistent-postgresql 0.9.0.2 → 0.9.1

raw patch · 3 files changed

+44/−47 lines, 3 filesdep ~bytestringdep ~postgresql-simple

Dependency ranges changed: bytestring, postgresql-simple

Files

Database/Persist/Postgresql.hs view
@@ -22,13 +22,14 @@ import qualified Database.PostgreSQL.Simple as PG import qualified Database.PostgreSQL.Simple.BuiltinTypes as PG import qualified Database.PostgreSQL.Simple.Internal as PG-import qualified Database.PostgreSQL.Simple.Param as PG-import qualified Database.PostgreSQL.Simple.Result as PG+import qualified Database.PostgreSQL.Simple.ToField as PGTF+import qualified Database.PostgreSQL.Simple.FromField as PGFF import qualified Database.PostgreSQL.Simple.Types as PG+import Database.PostgreSQL.Simple.Ok (Ok (..))  import qualified Database.PostgreSQL.LibPQ as LibPQ -import Control.Exception (SomeException, throw)+import Control.Exception (throw) import Control.Monad.IO.Class (MonadIO (..)) import Control.Monad.Trans.Control (MonadBaseControl) import Data.List (intercalate)@@ -203,31 +204,32 @@                                 case mbs of                                   Nothing -> return PersistNull                                   Just bs -> bs `seq` case getter mbs of-                                                        Left exc -> throw exc-                                                        Right v  -> return v+                                                        Errors (exc:_) -> throw exc+                                                        Errors [] -> error "Got an Errors, but no exceptions"+                                                        Ok v  -> return v  -- | Avoid orphan instances. newtype P = P PersistValue -instance PG.Param P where-    render (P (PersistText t))        = PG.render t-    render (P (PersistByteString bs)) = PG.render (PG.Binary bs)-    render (P (PersistInt64 i))       = PG.render i-    render (P (PersistDouble d))      = PG.render d-    render (P (PersistBool b))        = PG.render b-    render (P (PersistDay d))         = PG.render d-    render (P (PersistTimeOfDay t))   = PG.render t-    render (P (PersistUTCTime t))     = PG.render t-    render (P PersistNull)            = PG.render PG.Null-    render (P (PersistList l))        = PG.render $ listToJSON l-    render (P (PersistMap m))         = PG.render $ mapToJSON m-    render (P (PersistObjectId _))    =+instance PGTF.ToField P where+    toField (P (PersistText t))        = PGTF.toField t+    toField (P (PersistByteString bs)) = PGTF.toField (PG.Binary bs)+    toField (P (PersistInt64 i))       = PGTF.toField i+    toField (P (PersistDouble d))      = PGTF.toField d+    toField (P (PersistBool b))        = PGTF.toField b+    toField (P (PersistDay d))         = PGTF.toField d+    toField (P (PersistTimeOfDay t))   = PGTF.toField t+    toField (P (PersistUTCTime t))     = PGTF.toField t+    toField (P PersistNull)            = PGTF.toField PG.Null+    toField (P (PersistList l))        = PGTF.toField $ listToJSON l+    toField (P (PersistMap m))         = PGTF.toField $ mapToJSON m+    toField (P (PersistObjectId _))    =         error "Refusing to serialize a PersistObjectId to a PostgreSQL value" -type Getter a = PG.Field -> Maybe ByteString -> Either SomeException a+type Getter a = PG.Field -> Maybe ByteString -> Ok a -convertPV :: PG.Result a => (a -> b) -> Getter b-convertPV f = (fmap f .) . PG.convert+convertPV :: PGFF.FromField a => (a -> b) -> Getter b+convertPV f = (fmap f .) . PGFF.fromField  -- FIXME: check if those are correct and complete. getGetter :: PG.BuiltinType -> Getter PersistValue@@ -253,7 +255,7 @@ getGetter PG.Bit       = convertPV PersistInt64 getGetter PG.Varbit    = convertPV PersistInt64 getGetter PG.Numeric   = convertPV (PersistDouble . fromRational)-getGetter PG.Void      = \_ _ -> Right PersistNull+getGetter PG.Void      = \_ _ -> Ok PersistNull getGetter other   = error $ "Postgresql.getGetter: type " ++                             show other ++ " not supported." 
LICENSE view
@@ -1,25 +1,20 @@-The following license covers this documentation, and the source code, except-where otherwise indicated.--Copyright 2010, Michael Snoyman. All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are met:+Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/ -* Redistributions of source code must retain the above copyright notice, this-  list of conditions and the following disclaimer.+Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions: -* Redistributions in binary form must reproduce the above copyright notice,-  this list of conditions and the following disclaimer in the documentation-  and/or other materials provided with the distribution.+The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO-EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,-OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
persistent-postgresql.cabal view
@@ -1,5 +1,5 @@ name:            persistent-postgresql-version:         0.9.0.2+version:         0.9.1 license:         MIT license-file:    LICENSE author:          Felipe Lessa, Michael Snoyman <michael@snoyman.com>@@ -15,11 +15,11 @@ library     build-depends:   base                  >= 4        && < 5                    , transformers          >= 0.2.1    && < 0.4-                   , postgresql-simple     >= 0.0.3    && < 0.1+                   , postgresql-simple     >= 0.1      && < 0.2                    , postgresql-libpq      >= 0.6.1    && < 0.9                    , persistent            >= 0.9      && < 0.10                    , containers            >= 0.2-                   , bytestring            >= 0.9      && < 0.10+                   , bytestring            >= 0.9                    , text                  >= 0.7      && < 0.12                    , monad-control         >= 0.2      && < 0.4                    , time                  >= 1.1