persistent-qq 2.12.0.6 → 2.12.0.7
raw patch · 4 files changed
+81/−70 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−0
- persistent-qq.cabal +39/−38
- src/Database/Persist/Sql/Raw/QQ.hs +6/−6
- test/PersistentTestModels.hs +32/−26
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for persistent-qq +## 2.12.0.7+* [#1601](https://github.com/yesodweb/persistent/pull/1601)+ * Adjust a test to avoid deprecated entity definition syntax+ ## 2.12.0.6 * Fix test compilation by importing `Control.Monad` explicitly [#1487](https://github.com/yesodweb/persistent/pull/1487)
persistent-qq.cabal view
@@ -1,67 +1,68 @@-cabal-version: 1.12-name: persistent-qq-version: 2.12.0.6-synopsis: Provides a quasi-quoter for raw SQL for persistent-description: Please see README and API docs at <http://www.stackage.org/package/persistent>.-category: Database, Yesod-homepage: https://github.com/yesodweb/persistent#readme-bug-reports: https://github.com/yesodweb/persistent/issues-author: Michael Snoyman <michael@snoyman.com>-maintainer: Michael Snoyman <michael@snoyman.com>-license: MIT-license-file: LICENSE-build-type: Simple+cabal-version: 1.12+name: persistent-qq+version: 2.12.0.7+synopsis: Provides a quasi-quoter for raw SQL for persistent+description:+ Please see README and API docs at <http://www.stackage.org/package/persistent>.++category: Database, Yesod+homepage: https://github.com/yesodweb/persistent#readme+bug-reports: https://github.com/yesodweb/persistent/issues+author: Michael Snoyman <michael@snoyman.com>+maintainer: Michael Snoyman <michael@snoyman.com>+license: MIT+license-file: LICENSE+build-type: Simple extra-source-files:- ChangeLog.md- README.md+ ChangeLog.md+ README.md source-repository head- type: git+ type: git location: https://github.com/yesodweb/persistent library- exposed-modules:- Database.Persist.Sql.Raw.QQ- other-modules:- Paths_persistent_qq- hs-source-dirs:- src- ghc-options: -Wall+ exposed-modules: Database.Persist.Sql.Raw.QQ+ other-modules: Paths_persistent_qq+ hs-source-dirs: src+ ghc-options: -Wall build-depends:- base >=4.9 && <5+ base >=4.9 && <5 , haskell-src-meta , mtl- , persistent >=2.12+ , persistent >=2.12 , template-haskell , text+ default-language: Haskell2010 test-suite specs- type: exitcode-stdio-1.0- main-is: Spec.hs+ type: exitcode-stdio-1.0+ main-is: Spec.hs other-modules:- PersistentTestModels- PersistTestPetCollarType- PersistTestPetType- CodeGenTest- hs-source-dirs:- test- ghc-options: -Wall+ CodeGenTest+ PersistentTestModels+ PersistTestPetCollarType+ PersistTestPetType++ hs-source-dirs: test+ ghc-options: -Wall build-depends:- HUnit- , aeson+ aeson , base+ , bytestring , fast-logger , haskell-src-meta , hspec+ , HUnit , monad-logger , mtl- , persistent >=2.14+ , persistent >=2.14 , persistent-qq , persistent-sqlite , resourcet , template-haskell , text , unliftio- , bytestring+ default-language: Haskell2010
src/Database/Persist/Sql/Raw/QQ.hs view
@@ -6,7 +6,7 @@ This module exports convenient QuasiQuoters to perform raw SQL queries. All QuasiQuoters follow the same pattern and are analogous to the similar named-functions exported from 'Database.Persist.Sql.Raw'. Neither the quoted+functions exported from 'Database.Persist.Sql'. Neither the quoted function's behaviour, nor it's return value is altered during the translation and all documentation provided with it holds. @@ -158,7 +158,7 @@ (error "Cannot use qc as a dec") -- | QuasiQuoter for performing raw sql queries, analoguous to--- 'Database.Persist.Sql.Raw.rawSql'+-- 'Database.Persist.Sql.rawSql' -- -- This and the following are convenient QuasiQuoters to perform raw SQL -- queries. They each follow the same pattern and are analogous to@@ -207,25 +207,25 @@ sqlQQ :: QuasiQuoter sqlQQ = makeQQ [| rawSql |] --- | Analoguous to 'Database.Persist.Sql.Raw.rawExecute'+-- | Analoguous to 'Database.Persist.Sql.rawExecute' -- -- @since 2.9.0 executeQQ :: QuasiQuoter executeQQ = makeQQ [| rawExecute |] --- | Analoguous to 'Database.Persist.Sql.Raw.rawExecuteCount'+-- | Analoguous to 'Database.Persist.Sql.rawExecuteCount' -- -- @since 2.9.0 executeCountQQ :: QuasiQuoter executeCountQQ = makeQQ [| rawExecuteCount |] --- | Analoguous to 'Database.Persist.Sql.Raw.rawQuery'+-- | Analoguous to 'Database.Persist.Sql.rawQuery' -- -- @since 2.9.0 queryQQ :: QuasiQuoter queryQQ = makeQQ [| rawQuery |] --- | Analoguous to 'Database.Persist.Sql.Raw.rawQueryRes'+-- | Analoguous to 'Database.Persist.Sql.rawQueryRes' -- -- @since 2.9.0 queryResQQ :: QuasiQuoter
test/PersistentTestModels.hs view
@@ -11,7 +11,6 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-}- {-# OPTIONS_GHC -ddump-splices #-} module PersistentTestModels where@@ -29,16 +28,17 @@ import PersistTestPetType share- [ mkPersist sqlSettings { mpsGeneric = True }+ [ mkPersist sqlSettings{mpsGeneric = True} , mkMigrate "testMigrate"- ] [persistUpperCase|+ ]+ [persistUpperCase| -- Dedented comment -- Header-level comment -- Indented comment Person json name Text- age Int "some ignored -- \" attribute"+ age Int some="ignored -- \" attribute" color Text Maybe -- this is a comment sql=foobarbaz PersonNameKey name -- this is a comment sql=foobarbaz deriving Show Eq@@ -112,12 +112,14 @@ |] -deriving instance Show (BackendKey backend) => Show (PetGeneric backend)-deriving instance Eq (BackendKey backend) => Eq (PetGeneric backend)+deriving instance (Show (BackendKey backend)) => Show (PetGeneric backend)+deriving instance (Eq (BackendKey backend)) => Eq (PetGeneric backend) -share [ mkPersist sqlSettings { mpsPrefixFields = False, mpsGeneric = True }- , mkMigrate "noPrefixMigrate"- ] [persistLowerCase|+share+ [ mkPersist sqlSettings{mpsPrefixFields = False, mpsGeneric = True}+ , mkMigrate "noPrefixMigrate"+ ]+ [persistLowerCase| NoPrefix1 someFieldName Int NoPrefix2@@ -129,23 +131,27 @@ deriving Show Eq |] -deriving instance Show (BackendKey backend) => Show (NoPrefix1Generic backend)-deriving instance Eq (BackendKey backend) => Eq (NoPrefix1Generic backend)+deriving instance (Show (BackendKey backend)) => Show (NoPrefix1Generic backend)+deriving instance (Eq (BackendKey backend)) => Eq (NoPrefix1Generic backend) -deriving instance Show (BackendKey backend) => Show (NoPrefix2Generic backend)-deriving instance Eq (BackendKey backend) => Eq (NoPrefix2Generic backend)+deriving instance (Show (BackendKey backend)) => Show (NoPrefix2Generic backend)+deriving instance (Eq (BackendKey backend)) => Eq (NoPrefix2Generic backend) -- | Reverses the order of the fields of an entity. Used to test -- @??@ placeholders of 'rawSql'. newtype ReverseFieldOrder a = RFO {unRFO :: a} deriving (Eq, Show)-instance ToJSON (Key (ReverseFieldOrder a)) where toJSON = error "ReverseFieldOrder"-instance FromJSON (Key (ReverseFieldOrder a)) where parseJSON = error "ReverseFieldOrder"++instance ToJSON (Key (ReverseFieldOrder a)) where+ toJSON = error "ReverseFieldOrder"+instance FromJSON (Key (ReverseFieldOrder a)) where+ parseJSON = error "ReverseFieldOrder" instance (PersistEntity a) => PersistEntity (ReverseFieldOrder a) where type PersistEntityBackend (ReverseFieldOrder a) = PersistEntityBackend a - newtype Key (ReverseFieldOrder a) = RFOKey { unRFOKey :: BackendKey SqlBackend } deriving (Show, Read, Eq, Ord, PersistField, PersistFieldSql)+ newtype Key (ReverseFieldOrder a) = RFOKey {unRFOKey :: BackendKey SqlBackend}+ deriving (Show, Read, Eq, Ord, PersistField, PersistFieldSql) keyFromValues = fmap RFOKey . fromPersistValue . head- keyToValues = (:[]) . toPersistValue . unRFOKey+ keyToValues = (: []) . toPersistValue . unRFOKey entityDef = revFields . entityDef . unRfoProxy where@@ -158,7 +164,7 @@ persistFieldDef = persistFieldDef . unEFRFO fromPersistValues = fmap RFO . fromPersistValues . reverse - newtype Unique (ReverseFieldOrder a) = URFO {unURFO :: Unique a }+ newtype Unique (ReverseFieldOrder a) = URFO {unURFO :: Unique a} persistUniqueToFieldNames = NEL.reverse . persistUniqueToFieldNames . unURFO persistUniqueToValues = reverse . persistUniqueToValues . unURFO persistUniqueKeys = map URFO . reverse . persistUniqueKeys . unRFO@@ -170,11 +176,11 @@ :: (MonadIO m, PersistQuery backend, PersistStoreWrite (BaseBackend backend)) => ReaderT backend m () cleanDB = do- deleteWhere ([] :: [Filter (PersonGeneric backend)])- deleteWhere ([] :: [Filter (Person1Generic backend)])- deleteWhere ([] :: [Filter (PetGeneric backend)])- deleteWhere ([] :: [Filter (MaybeOwnedPetGeneric backend)])- deleteWhere ([] :: [Filter (NeedsPetGeneric backend)])- deleteWhere ([] :: [Filter (OutdoorPetGeneric backend)])- deleteWhere ([] :: [Filter (UserPTGeneric backend)])- deleteWhere ([] :: [Filter (EmailPTGeneric backend)])+ deleteWhere ([] :: [Filter (PersonGeneric backend)])+ deleteWhere ([] :: [Filter (Person1Generic backend)])+ deleteWhere ([] :: [Filter (PetGeneric backend)])+ deleteWhere ([] :: [Filter (MaybeOwnedPetGeneric backend)])+ deleteWhere ([] :: [Filter (NeedsPetGeneric backend)])+ deleteWhere ([] :: [Filter (OutdoorPetGeneric backend)])+ deleteWhere ([] :: [Filter (UserPTGeneric backend)])+ deleteWhere ([] :: [Filter (EmailPTGeneric backend)])