packages feed

composite-opaleye 0.7.5.0 → 0.8.0.0

raw patch · 4 files changed

+80/−54 lines, 4 filesdep ~basedep ~bytestringdep ~composite-base

Dependency ranges changed: base, bytestring, composite-base, lens, opaleye, profunctors, template-haskell, vinyl

Files

composite-opaleye.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.3.+-- This file has been generated from package.yaml by hpack version 0.34.5. -- -- see: https://github.com/sol/hpack ----- hash: f36b567442bdd52febf8ef607bf0a41795c161ef0d2ac08d9d9f10eeee4dc39e+-- hash: 03ab7de21f52bc22bd073870d37886f0591c8fa2ee7a704f32d4e385ecbcc622  name:           composite-opaleye-version:        0.7.5.0+version:        0.8.0.0 synopsis:       Opaleye SQL for Vinyl records description:    Integration between Vinyl records and Opaleye SQL, allowing records to be stored, retrieved, and queried from PostgreSQL. category:       Records@@ -30,20 +30,34 @@       Paths_composite_opaleye   hs-source-dirs:       src-  default-extensions: DataKinds FlexibleContexts FlexibleInstances LambdaCase MultiParamTypeClasses OverloadedStrings PatternSynonyms PolyKinds ScopedTypeVariables StrictData TemplateHaskell TypeFamilies TypeOperators ViewPatterns+  default-extensions:+      DataKinds+      FlexibleContexts+      FlexibleInstances+      LambdaCase+      MultiParamTypeClasses+      OverloadedStrings+      PatternSynonyms+      PolyKinds+      ScopedTypeVariables+      StrictData+      TemplateHaskell+      TypeFamilies+      TypeOperators+      ViewPatterns   ghc-options: -Wall -O2   build-depends:-      base >=4.7 && <5-    , bytestring >=0.10.8.1 && <0.11-    , composite-base >=0.7 && <0.8-    , lens >=4.15.4 && <5.1-    , opaleye >=0.5.4.0 && <0.8+      base >=4.12 && <5+    , bytestring >=0.10.8.1 && <0.12+    , composite-base ==0.8.*+    , lens >=4.15.4 && <5.2+    , opaleye >=0.5.4.0 && <0.10     , postgresql-simple >=0.5.3.0 && <0.7     , product-profunctors >=0.8.0.3 && <0.12-    , profunctors >=5.2.1 && <5.6-    , template-haskell >=2.11.1.0 && <2.17+    , profunctors >=5.2.1 && <5.7+    , template-haskell >=2.11.1.0 && <2.19     , text >=1.2.2.2 && <1.3-    , vinyl >=0.5.3 && <0.14+    , vinyl >=0.5.3 && <0.15   default-language: Haskell2010  test-suite composite-opaleye-test@@ -54,21 +68,35 @@       Paths_composite_opaleye   hs-source-dirs:       test-  default-extensions: DataKinds FlexibleContexts FlexibleInstances LambdaCase MultiParamTypeClasses OverloadedStrings PatternSynonyms PolyKinds ScopedTypeVariables StrictData TemplateHaskell TypeFamilies TypeOperators ViewPatterns+  default-extensions:+      DataKinds+      FlexibleContexts+      FlexibleInstances+      LambdaCase+      MultiParamTypeClasses+      OverloadedStrings+      PatternSynonyms+      PolyKinds+      ScopedTypeVariables+      StrictData+      TemplateHaskell+      TypeFamilies+      TypeOperators+      ViewPatterns   ghc-options: -Wall -O2 -threaded -rtsopts -with-rtsopts=-N -fno-warn-orphans   build-depends:       QuickCheck-    , base >=4.7 && <5-    , bytestring >=0.10.8.1 && <0.11-    , composite-base >=0.7 && <0.8+    , base >=4.12 && <5+    , bytestring >=0.10.8.1 && <0.12+    , composite-base ==0.8.*     , composite-opaleye     , hspec-    , lens >=4.15.4 && <5.1-    , opaleye >=0.5.4.0 && <0.8+    , lens >=4.15.4 && <5.2+    , opaleye >=0.5.4.0 && <0.10     , postgresql-simple >=0.5.3.0 && <0.7     , product-profunctors >=0.8.0.3 && <0.12-    , profunctors >=5.2.1 && <5.6-    , template-haskell >=2.11.1.0 && <2.17+    , profunctors >=5.2.1 && <5.7+    , template-haskell >=2.11.1.0 && <2.19     , text >=1.2.2.2 && <1.3-    , vinyl >=0.5.3 && <0.14+    , vinyl >=0.5.3 && <0.15   default-language: Haskell2010
src/Composite/Opaleye/RecordTable.hs view
@@ -7,42 +7,42 @@ import qualified Data.Profunctor.Product as PP import Data.Proxy (Proxy(Proxy)) import GHC.TypeLits (KnownSymbol, symbolVal)-import Opaleye (Column, required, optional)-import Opaleye.Internal.Table (TableProperties)+import Opaleye (Field, requiredTableField, optionalTableField)+import Opaleye.Internal.Table (TableFields) --- |Helper typeclass which picks which of 'required' or 'optional' to use for a pair of write column type and read column type.+-- |Helper typeclass which picks which of 'requiredTableField' or 'optionalTableField' to use for a pair of write column type and read column type. ----- @DefaultRecTableField (Maybe (Column a)) (Column a)@ uses 'optional'.--- @DefaultRecTableField        (Column a)  (Column a)@ uses 'required'.+-- @DefaultRecTableField (Maybe (Field a)) (Field a)@ uses 'optionalTableField'.+-- @DefaultRecTableField        (Field a)  (Field a)@ uses 'requiredTableField'. class DefaultRecTableField write read where-  defaultRecTableField :: String -> TableProperties write read+  defaultRecTableField :: String -> TableFields write read -instance DefaultRecTableField (Maybe (Column a)) (Column a) where-  defaultRecTableField = optional+instance DefaultRecTableField (Maybe (Field a)) (Field a) where+  defaultRecTableField = optionalTableField -instance DefaultRecTableField (Column a) (Column a) where-  defaultRecTableField = required+instance DefaultRecTableField (Field a) (Field a) where+  defaultRecTableField = requiredTableField --- |Type class for producing a default 'TableProperties' schema for some expected record types. 'required' and 'optional' are chosen automatically and the+-- |Type class for producing a default 'TableFields' schema for some expected record types. 'requiredTableField' and 'optionalTableField' are chosen automatically and the -- column is named after the record fields, using 'NamedField' to reflect the field names. -- -- For example, given: ----- >  type WriteRec = Record '["id" :-> Maybe (Column PGInt8), "name" :-> Column PGText]--- >  type ReadRec  = Record '["id" :->        Column PGInt8 , "name" :-> Column PGText]+-- >  type WriteRec = Record '["id" :-> Maybe (Field PGInt8), "name" :-> Field PGText]+-- >  type ReadRec  = Record '["id" :->        Field PGInt8 , "name" :-> Field PGText] -- -- This: ----- >  defaultRecTable :: TableProperties WriteRec ReadRec+-- >  defaultRecTable :: TableFields WriteRec ReadRec -- -- Is equivalent to: ----- > pRec (optional "id" &: required "name" &: Nil)+-- > pRec (optionalTableField "id" &: requiredTableField "name" &: Nil) -- ----- Alternately, use 'Composite.Opaleye.ProductProfunctors.pRec' and the usual Opaleye 'required' and 'optional'.+-- Alternately, use 'Composite.Opaleye.ProductProfunctors.pRec' and the usual Opaleye 'requiredTableField' and 'optionalTableField'. class DefaultRecTable write read where-  defaultRecTable :: TableProperties (Rec Identity write) (Rec Identity read)+  defaultRecTable :: TableFields (Rec Identity write) (Rec Identity read)  instance DefaultRecTable '[] '[] where   defaultRecTable = dimap (const ()) (const RNil) PP.empty@@ -58,8 +58,7 @@           (\ (r, readRs) -> (Identity (Val r) :& readRs))           (step  ***! recur)     where-      step :: TableProperties w r+      step :: TableFields w r       step = defaultRecTableField $ symbolVal (Proxy :: Proxy s)-      recur :: TableProperties (Rec Identity writes) (Rec Identity reads)+      recur :: TableFields (Rec Identity writes) (Rec Identity reads)       recur = defaultRecTable-
src/Composite/Opaleye/TH.hs view
@@ -22,7 +22,7 @@   ) import Language.Haskell.TH.Syntax (lift) import Opaleye-  ( Column, Constant(..), QueryRunnerColumnDefault, ToFields, fieldQueryRunnerColumn, queryRunnerColumnDefault+  ( Column, DefaultFromField, ToFields, fromPGSFromField, defaultFromField   ) import Opaleye.Internal.PGTypes (IsSqlType, showSqlType, literalColumn) import Opaleye.Internal.HaskellDB.PrimQuery (Literal(StringLit))@@ -73,11 +73,11 @@ --           Just other -> 'returnError' 'ConversionFailed' f ("Unexpected myschema.myenum value: " <> 'BSC8.unpack' other) --           Nothing    -> 'returnError' 'UnexpectedNull' f "" -----     instance 'QueryRunnerColumnDefault' PGMyEnum MyEnum where---       queryRunnerColumnDefault = 'fieldQueryRunnerColumn'+--     instance 'DefaultFromField' PGMyEnum MyEnum where+--       defaultFromField = 'fromPGSFromField' -- --     instance 'Default' 'ToFields' MyEnum ('Column' PGMyEnum) where---       def = 'Constant' $ \ a ->+--       def = 'ToFields' $ \ a -> --         'literalColumn' . 'stringLit' $ case a of --           MyFoo -> "foo" --           MyBar -> "bar"@@ -165,11 +165,11 @@           []       ] -  queryRunnerColumnDefaultInst <- instanceD (cxt []) [t| QueryRunnerColumnDefault $sqlType $hsType |] . (:[]) $-    funD 'queryRunnerColumnDefault+  defaultFromFieldInst <- instanceD (cxt []) [t| DefaultFromField $sqlType $hsType |] . (:[]) $+    funD 'defaultFromField       [ clause           []-          (normalB [| fieldQueryRunnerColumn |])+          (normalB [| fromPGSFromField |])           []       ] @@ -186,9 +186,8 @@     funD 'def       [ clause           []-          (normalB [| Constant (literalColumn . StringLit . $body) |])+          (normalB [| ToFields (literalColumn . StringLit . $body) |])           []       ] -  pure [sqlTypeDecl, isSqlTypeInst, fromFieldInst, queryRunnerColumnDefaultInst, defaultInst]-+  pure [sqlTypeDecl, isSqlTypeInst, fromFieldInst, defaultFromFieldInst, defaultInst]
src/Composite/Opaleye/Util.hs view
@@ -1,11 +1,11 @@ module Composite.Opaleye.Util where  import Data.Profunctor (dimap)-import Opaleye (Column, ToFields, unsafeCoerceColumn)+import Opaleye (Field, ToFields, unsafeCoerceColumn)  -- |Coerce one type of 'Column' 'ToFields' profunctor to another using by just asserting the changed type on the column side and using the given function -- on the Haskell side. Useful when the PG value representation is the same but the Haskell type changes, e.g. for enums.-constantColumnUsing :: ToFields haskell (Column sqlType)+constantColumnUsing :: ToFields haskell (Field sqlType)                     -> (haskell' -> haskell)-                    -> ToFields haskell' (Column sqlType')+                    -> ToFields haskell' (Field sqlType') constantColumnUsing oldToFields f = dimap f unsafeCoerceColumn oldToFields