postgresql-typed 0.6.1.0 → 0.6.1.1
raw patch · 6 files changed
+41/−14 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Database.PostgreSQL.Typed.Query: getQueryString :: PGQuery q a => PGConnection -> q -> ByteString
+ Database.PostgreSQL.Typed.Query: getQueryString :: PGQuery q a => PGTypeEnv -> q -> ByteString
Files
- Database/PostgreSQL/Typed/Enum.hs +9/−2
- Database/PostgreSQL/Typed/Query.hs +2/−2
- Database/PostgreSQL/Typed/Relation.hs +9/−2
- Database/PostgreSQL/Typed/TemplatePG.hs +13/−4
- postgresql-typed.cabal +7/−3
- test/Main.hs +1/−1
Database/PostgreSQL/Typed/Enum.hs view
@@ -91,7 +91,7 @@ #endif [''Eq, ''Ord, ''Enum, ''Ix, ''Bounded, ''Typeable] , instanceD [] (TH.ConT ''PGType `TH.AppT` typl)- [ TH.TySynInstD ''PGVal $ TH.TySynEqn [typl] typt+ [ tySynInstD ''PGVal typl typt ] , instanceD [] (TH.ConT ''PGParameter `TH.AppT` typl `TH.AppT` typt) [ TH.FunD 'pgEncode [TH.Clause [TH.WildP, TH.VarP dv]@@ -108,7 +108,7 @@ []] ] , instanceD [] (TH.ConT ''PGRep `TH.AppT` typt)- [ TH.TySynInstD ''PGRepType $ TH.TySynEqn [typt] typl+ [ tySynInstD ''PGRepType typt typl ] , instanceD [] (TH.ConT ''PGEnum `TH.AppT` typt) [ TH.FunD 'pgEnumName $ map (\(n, l) -> TH.Clause [TH.ConP n []]@@ -135,4 +135,11 @@ #if MIN_VERSION_template_haskell(2,11,0) Nothing #endif+ tySynInstD c l t = TH.TySynInstD+#if MIN_VERSION_template_haskell(2,15,0)+ $ TH.TySynEqn Nothing (TH.AppT (TH.ConT c) l)+#else+ c $ TH.TySynEqn [l]+#endif+ t namelit l = TH.ConE 'PGName `TH.AppE` TH.ListE (map TH.LitE l)
Database/PostgreSQL/Typed/Query.hs view
@@ -52,7 +52,7 @@ -- -- > [pgSQL|SELECT a FROM t|] `unsafeModifyQuery` (<> (" WHERE a = " <> pgSafeLiteral x)) unsafeModifyQuery :: q -> (BS.ByteString -> BS.ByteString) -> q- getQueryString :: PGConnection -> q -> BS.ByteString+ getQueryString :: PGTypeEnv -> q -> BS.ByteString class PGQuery q PGValues => PGRawQuery q -- |Execute a query that does not return results.@@ -90,7 +90,7 @@ instance PGRawQuery q => PGQuery (QueryParser q a) a where pgRunQuery c (QueryParser q p) = second (fmap $ p e) <$> pgRunQuery c (q e) where e = pgTypeEnv c unsafeModifyQuery (QueryParser q p) f = QueryParser (\e -> unsafeModifyQuery (q e) f) p- getQueryString c (QueryParser q _) = getQueryString c $ q $ pgTypeEnv c+ getQueryString e (QueryParser q _) = getQueryString e $ q e instance Functor (QueryParser q) where fmap f (QueryParser q p) = QueryParser q (\e -> f . p e)
Database/PostgreSQL/Typed/Relation.hs view
@@ -114,7 +114,7 @@ ] [] , instanceD [] (TH.ConT ''PGType `TH.AppT` typl)- [ TH.TySynInstD ''PGVal $ TH.TySynEqn [typl] typt+ [ tySynInstD ''PGVal typl typt ] , instanceD [] (TH.ConT ''PGParameter `TH.AppT` typl `TH.AppT` typt) [ encfun 'pgEncode@@ -158,7 +158,7 @@ ] #endif , instanceD [] (TH.ConT ''PGRep `TH.AppT` typt)- [ TH.TySynInstD ''PGRepType $ TH.TySynEqn [typt] typl+ [ tySynInstD ''PGRepType typt typl ] , instanceD [] (TH.ConT ''PGRecordType `TH.AppT` typl) [] , instanceD [] (TH.ConT ''PGRelation `TH.AppT` typt)@@ -191,6 +191,13 @@ #if MIN_VERSION_template_haskell(2,11,0) Nothing #endif+ tySynInstD c l t = TH.TySynInstD+#if MIN_VERSION_template_haskell(2,15,0)+ $ TH.TySynEqn Nothing (TH.AppT (TH.ConT c) l)+#else+ c $ TH.TySynEqn [l]+#endif+ t pgcall f t = TH.VarE f `TH.AppE` (TH.ConE 'PGTypeProxy `TH.SigE` (TH.ConT ''PGTypeID `TH.AppT` t))
Database/PostgreSQL/Typed/TemplatePG.hs view
@@ -21,7 +21,7 @@ , rollback , PGException , pgConnect-#if !MIN_VERSION_network(3,0,0)+#if !MIN_VERSION_network(2,7,0) , PortID(..) #endif , PG.pgDisconnect@@ -34,12 +34,14 @@ import qualified Data.ByteString.Lazy.Char8 as BSLC import Data.Maybe (listToMaybe, isJust) import qualified Language.Haskell.TH as TH-#if MIN_VERSION_network(3,0,0)+#if MIN_VERSION_network(2,7,0) import Data.Word (Word16) #else import Network (PortID(..)) #endif+#if !defined(mingw32_HOST_OS) import qualified Network.Socket as Net+#endif import System.Environment (lookupEnv) import qualified Database.PostgreSQL.Typed.Protocol as PG@@ -99,10 +101,15 @@ type PGException = PG.PGError -#if MIN_VERSION_network(3,0,0)+#if MIN_VERSION_network(2,7,0) -- |For backwards compatibility with old network package.-data PortID = Service String | PortNumber Word16 | UnixSocket String+data PortID+ = Service String+ | PortNumber Word16+#if !defined(mingw32_HOST_OS)+ | UnixSocket String #endif+#endif pgConnect :: String -- ^ the host to connect to -> PortID -- ^ the port to connect on@@ -116,7 +123,9 @@ { PG.pgDBAddr = case n of PortNumber s -> Left (h, show s) Service s -> Left (h, s)+#if !defined(mingw32_HOST_OS) UnixSocket s -> Right (Net.SockAddrUnix s)+#endif , PG.pgDBName = d , PG.pgDBUser = u , PG.pgDBPass = p
postgresql-typed.cabal view
@@ -1,6 +1,6 @@ Name: postgresql-typed-Version: 0.6.1.0-Cabal-Version: >= 1.8+Version: 0.6.1.1+Cabal-Version: >= 1.10 License: BSD3 License-File: COPYING Copyright: 2010-2013 Chris Forno, 2014-2019 Dylan Simon@@ -59,6 +59,7 @@ Default: True Library+ default-language: Haskell2010 Build-Depends: base >= 4.8 && < 5, array,@@ -112,17 +113,19 @@ Build-Depends: data-default, tls, x509, x509-store, x509-validation test-suite test+ default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Main.hs Other-Modules: Connect- Extensions: TemplateHaskell, QuasiQuotes+ default-Extensions: TemplateHaskell, QuasiQuotes build-depends: base, network, time, bytestring, postgresql-typed, QuickCheck GHC-Options: -Wall if flag(tls) Build-Depends: tls test-suite hdbc+ default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: test/hdbc, test main-is: runtests.hs@@ -143,6 +146,7 @@ Build-Depends: tls benchmark bench+ default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Bench.hs
test/Main.hs view
@@ -137,7 +137,7 @@ $ selectProp c Q..&&. tokenProp Q..&&. [pgSQL|#abc ${3.14::Float} def $f$ $$ ${1} $f$${2::Int32}|] Q.=== "abc 3.14::real def $f$ $$ ${1} $f$2::integer"- Q..&&. getQueryString c ([pgSQL|SELECT ${"ab'cd"::String}::text, ${3.14::Float}::float4|] :: PGSimpleQuery (Maybe String, Maybe Float)) Q.=== "SELECT 'ab''cd'::text, 3.14::float4"+ Q..&&. getQueryString (pgTypeEnv c) ([pgSQL|SELECT ${"ab'cd"::String}::text, ${3.14::Float}::float4|] :: PGSimpleQuery (Maybe String, Maybe Float)) Q.=== "SELECT 'ab''cd'::text, 3.14::float4" Q..&&. pgEnumValues Q.=== [(MyEnum_abc, "abc"), (MyEnum_DEF, "DEF"), (MyEnum_XX_ye, "XX_ye")] Q..&&. Q.conjoin (map (\(s, t) -> sqlTokens s Q.=== t) [ ("",