packages feed

opaleye 0.10.2.3 → 0.10.3.0

raw patch · 5 files changed

+39/−3 lines, 5 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

+ Opaleye.Experimental.Enum: enumShowSqlType :: EnumMapper sqlEnum haskellSum -> forall proxy. proxy sqlEnum -> String
+ Opaleye.Internal.PGTypes: sqlTypeWithSchema :: String -> String -> String
+ Opaleye.SqlTypes: sqlTypeWithSchema :: String -> String -> String

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+## 0.10.3.0++* Added `enumShowSqlType` and `sqlTypeWithSchema` (thanks to+  @stevemao)+ ## 0.10.2.3  * Documentation improvements
opaleye.cabal view
@@ -1,6 +1,6 @@ name:            opaleye copyright:       Copyright (c) 2014-2018 Purely Agile Limited; 2019-2024 Tom Ellis-version:         0.10.2.3+version:         0.10.3.0 synopsis:        An SQL-generating DSL targeting PostgreSQL description:     An SQL-generating DSL targeting PostgreSQL.  Allows                  Postgres queries to be written within Haskell in a
src/Opaleye/Experimental/Enum.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE RankNTypes #-}  module Opaleye.Experimental.Enum   (@@ -7,19 +8,22 @@     enumMapperWithSchema,     enumFromField,     enumToFields,+    enumShowSqlType,   ) where  import           Opaleye.Field (Field) import qualified Opaleye as O+import qualified Opaleye.Internal.PGTypes as IPT import qualified Opaleye.Internal.RunQuery as RQ  import           Data.ByteString.Char8 (unpack)-import Text.PrettyPrint.HughesPJ ((<>), doubleQuotes, render, text)+import Text.PrettyPrint.HughesPJ (doubleQuotes, render, text) import Prelude hiding ((<>))  data EnumMapper sqlEnum haskellSum = EnumMapper {     enumFromField :: RQ.FromField sqlEnum haskellSum   , enumToFields :: O.ToFields haskellSum (Field sqlEnum)+  , enumShowSqlType :: forall proxy. proxy sqlEnum -> String   }  -- | Create a mapping between a Postgres @ENUM@ type and a Haskell@@ -83,6 +87,9 @@ -- -- instance D.Default O.ToFields Rating (O.Field SqlRating) where --   def = enumToFields sqlRatingMapper+--+-- instance IsSqlType SqlRating where+--   showSqlType = enumShowSqlType sqlRatingMapper -- @ enumMapper :: String            -- ^ The name of the @ENUM@ type@@ -112,7 +119,9 @@            -- ^ The @sqlEnum@ type variable is phantom. To protect            -- yourself against type mismatches you should set it to            -- the Haskell type that you use to represent the @ENUM@.-enumMapperWithSchema schema type_ = enumMapper' (render (doubleQuotes (text schema) <> text "." <> doubleQuotes (text type_)))+enumMapperWithSchema schema type_ =+  enumMapper'+    (IPT.sqlTypeWithSchema schema type_)  enumMapper' :: String            -- ^ The name of the @ENUM@ type@@ -129,6 +138,7 @@ enumMapper' type_ from to_ = EnumMapper {     enumFromField = fromFieldEnum   , enumToFields = toFieldsEnum+  , enumShowSqlType = \_ -> type_   }    where      toFieldsEnum = O.toToFields (O.unsafeCast type_ . O.sqlString . to_)
src/Opaleye/Internal/PGTypes.hs view
@@ -15,6 +15,8 @@ import qualified Data.ByteString as SByteString import qualified Data.ByteString.Lazy as LByteString import qualified Data.Time.Format.ISO8601.Compat as Time+import Text.PrettyPrint.HughesPJ ((<>), doubleQuotes, render, text)+import Prelude hiding ((<>))  unsafePgFormatTime :: Time.ISO8601 t => HPQ.Name -> t -> Field c unsafePgFormatTime typeName = castToType typeName . format@@ -34,6 +36,23 @@  lazyDecodeUtf8 :: LByteString.ByteString -> String lazyDecodeUtf8 = LText.unpack . LTextEncoding.decodeUtf8++-- | Render the name of a type with a schema+--+-- @+-- > putStrLn (sqlTypeWithSchema "my_schema" "my_type")+-- "my_schema"."my_type"+-- @+--+-- @+-- instance 'IsSqlType' SqlMyTypeWithSchema where+--   'showSqlType' = \\_ -> sqlTypeWithSchema "my_schema" "my_type"+-- @+sqlTypeWithSchema :: String -> String -> String+sqlTypeWithSchema schema type_ =+  render (doubleQuotes (text schema)+           <> text "."+           <> doubleQuotes (text type_))  class IsSqlType sqlType where   showSqlType :: proxy sqlType -> String
src/Opaleye/SqlTypes.hs view
@@ -90,10 +90,12 @@   SqlBytea,   -- * @IsSqlType@   P.IsSqlType(P.showSqlType),+  IPT.sqlTypeWithSchema,   ) where  import qualified Opaleye.Field   as F import qualified Opaleye.Internal.Column as IC+import qualified Opaleye.Internal.PGTypes as IPT import qualified Opaleye.Internal.PGTypesExternal as P import           Opaleye.Internal.PGTypesExternal (IsSqlType, IsRangeType) import           Opaleye.Internal.PGTypesExternal (SqlBool,