mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-10-05 06:18:04 +03:00
server: fix MySQL connection pool settings getting swapped on parse
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6063 GitOrigin-RevId: 90f6f8485aa6a9d073edc56dcba5530f5cf787c4
This commit is contained in:
parent
cbdacd1c6c
commit
d32dc881e3
@ -988,6 +988,7 @@ test-suite graphql-engine-tests
|
||||
Hasura.Backends.DataConnector.API.V0.TableSpec
|
||||
Hasura.Backends.MSSQL.ErrorSpec
|
||||
Hasura.Backends.MySQL.DataLoader.ExecuteTests
|
||||
Hasura.Backends.MySQL.TypesSpec
|
||||
Hasura.Backends.Postgres.Execute.PrepareSpec
|
||||
Hasura.Backends.Postgres.RQLGenerator
|
||||
Hasura.Backends.Postgres.RQLGenerator.GenAnnSelectG
|
||||
|
@ -199,8 +199,8 @@ instance Semigroup Top where
|
||||
instance J.FromJSON ConnPoolSettings where
|
||||
parseJSON = J.withObject "MySQL pool settings" $ \o ->
|
||||
ConnPoolSettings
|
||||
<$> o J..:? "max_connections" J..!= _cscMaxConnections defaultConnPoolSettings
|
||||
<*> o J..:? "idle_timeout" J..!= _cscIdleTimeout defaultConnPoolSettings
|
||||
<$> o J..:? "idle_timeout" J..!= _cscIdleTimeout defaultConnPoolSettings
|
||||
<*> o J..:? "max_connections" J..!= _cscMaxConnections defaultConnPoolSettings
|
||||
|
||||
$(J.deriveToJSON hasuraJSON ''ConnPoolSettings)
|
||||
|
||||
|
30
server/src-test/Hasura/Backends/MySQL/TypesSpec.hs
Normal file
30
server/src-test/Hasura/Backends/MySQL/TypesSpec.hs
Normal file
@ -0,0 +1,30 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Hasura.Backends.MySQL.TypesSpec (spec) where
|
||||
|
||||
import Data.Aeson (parseJSON, toJSON)
|
||||
import Data.Aeson.QQ (aesonQQ)
|
||||
import Data.Aeson.Types (parseEither)
|
||||
import Hasura.Backends.MySQL.Types (ConnPoolSettings (..))
|
||||
import Hasura.Prelude
|
||||
import Test.Hspec
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "MySQL" do
|
||||
describe "ConnPoolSettings" do
|
||||
it "should parse idle timeout and max connections" do
|
||||
let input =
|
||||
[aesonQQ|
|
||||
{ "idle_timeout": 100,
|
||||
"max_connections": 10
|
||||
}
|
||||
|]
|
||||
let decoded = parseEither parseJSON input
|
||||
let expected = ConnPoolSettings {_cscIdleTimeout = 100, _cscMaxConnections = 10}
|
||||
decoded `shouldBe` Right expected
|
||||
|
||||
it "should round-trip" do
|
||||
let expected = ConnPoolSettings {_cscIdleTimeout = 100, _cscMaxConnections = 10}
|
||||
let actual = parseEither parseJSON $ toJSON expected
|
||||
actual `shouldBe` Right expected
|
Loading…
Reference in New Issue
Block a user