persistent-mysql 2.13.0.3 → 2.13.0.4
raw patch · 5 files changed
+47/−3 lines, 5 filesdep ~conduitdep ~mysqldep ~mysql-simple
Dependency ranges changed: conduit, mysql, mysql-simple
Files
- ChangeLog.md +4/−0
- Database/Persist/MySQL.hs +3/−0
- persistent-mysql.cabal +5/−3
- test/JSONTest.hs +33/−0
- test/main.hs +2/−0
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for persistent-mysql +## 2.13.0.4++* No longer errors on `json` columns. [#1333](https://github.com/yesodweb/persistent/pull/1333)+ ## 2.13.0.3 * Bugfix: Omit `REFERENCES` in `CREATe TABLE` statements. These are ignored by
Database/Persist/MySQL.hs view
@@ -45,11 +45,13 @@ import Control.Monad.Trans.Except (ExceptT, runExceptT) import Control.Monad.Trans.Reader (ReaderT, runReaderT) import Control.Monad.Trans.Writer (runWriterT)+import Data.Proxy (Proxy(..)) import Data.Acquire (Acquire, mkAcquire, with) import Data.Aeson import Data.Aeson.Types (modifyFailure) import Data.ByteString (ByteString)+import qualified Data.ByteString.Lazy as BSL import Data.Conduit import qualified Data.Conduit.List as CL import Data.Either (partitionEithers)@@ -335,6 +337,7 @@ case m of Just g -> PersistLiteral g Nothing -> error "Unexpected null in database specific value"+ go MySQLBase.Json _ _ = convertPV PersistByteString -- Unsupported go other _ _ = error $ "MySQL.getGetter: type " ++ show other ++ " not supported."
persistent-mysql.cabal view
@@ -1,5 +1,5 @@ name: persistent-mysql-version: 2.13.0.3+version: 2.13.0.4 license: MIT license-file: LICENSE author: Felipe Lessa <felipe.lessa@gmail.com>, Michael Snoyman@@ -35,8 +35,8 @@ , conduit >= 1.2.12 , containers >= 0.5 , monad-logger- , mysql >= 0.1.4 && < 0.3- , mysql-simple >= 0.4.4 && < 0.5+ , mysql >= 0.2.1 && < 0.3+ , mysql-simple >= 0.4.7 && < 0.5 , resourcet >= 1.1 , resource-pool , text >= 1.2@@ -59,6 +59,7 @@ InsertDuplicateUpdate CustomConstraintTest ImplicitUuidSpec+ JSONTest ghc-options: -Wall build-depends: @@ -66,6 +67,7 @@ , aeson , bytestring , containers+ , conduit , fast-logger , hspec >= 2.4 , http-api-data
+ test/JSONTest.hs view
@@ -0,0 +1,33 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveAnyClass #-}+{-# LANGUAGE DerivingStrategies #-}+{-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}++module JSONTest where++import Data.Aeson+import Test.HUnit (assertBool)++import qualified Data.ByteString.Lazy as BSL+import Data.Conduit (runConduit, (.|))+import qualified Data.Conduit.List as CL+import Database.Persist.MySQL+import MyInit++specs :: Spec+specs = describe "JSONTest" $ do+ it "can select json with rawsql" $ db $ do+ let testJSON = toJSON $ [object [ "test" .= ("value" :: Text) ]]+ [[PersistByteString value]] <- runConduit $ rawQuery "select JSON_ARRAY(JSON_OBJECT('test', 'value'))" [] .| CL.consume+ liftIO $ Just testJSON `shouldBe` (decode $ BSL.fromStrict value)
test/main.hs view
@@ -54,6 +54,7 @@ import qualified ForeignKey import qualified GeneratedColumnTestSQL import qualified ImplicitUuidSpec+import qualified JSONTest import qualified LongIdentifierTest import qualified RenameTest import qualified SumTypeTest@@ -212,6 +213,7 @@ xdescribe "The migration for this test currently fails because of MySQL's 64 character limit for identifiers. See https://github.com/yesodweb/persistent/issues/1000 for details" $ LongIdentifierTest.specsWith db GeneratedColumnTestSQL.specsWith db+ JSONTest.specs roundFn :: RealFrac a => a -> Integer roundFn = round