Merge pull request #728 from steve-chavez/master
Fix fatal error on postgres unsupported version, also fix #577 format…
This commit is contained in:
@@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Fix bug in relation detection when selecting parents two levels up by using the name of the FK - @ruslantalpa
|
- Fix bug in relation detection when selecting parents two levels up by using the name of the FK - @ruslantalpa
|
||||||
- Customize content negotiation per route - @begriffs
|
- Customize content negotiation per route - @begriffs
|
||||||
- Allow using nulls order without explicit order direction - @steve-chavez
|
- Allow using nulls order without explicit order direction - @steve-chavez
|
||||||
|
- Fatal error on postgres unsupported version, format supported version in error message - @steve-chavez
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Use HTTP 400 for raise\_exception - @begriffs
|
- Use HTTP 400 for raise\_exception - @begriffs
|
||||||
|
|||||||
+5
-4
@@ -5,6 +5,7 @@ module Main where
|
|||||||
import Protolude
|
import Protolude
|
||||||
import PostgREST.App
|
import PostgREST.App
|
||||||
import PostgREST.Config (AppConfig (..),
|
import PostgREST.Config (AppConfig (..),
|
||||||
|
PgVersion (..),
|
||||||
minimumPgVersion,
|
minimumPgVersion,
|
||||||
prettyVersion,
|
prettyVersion,
|
||||||
readOptions)
|
readOptions)
|
||||||
@@ -34,11 +35,11 @@ import System.Posix.Signals
|
|||||||
isServerVersionSupported :: H.Session Bool
|
isServerVersionSupported :: H.Session Bool
|
||||||
isServerVersionSupported = do
|
isServerVersionSupported = do
|
||||||
ver <- H.query () pgVersion
|
ver <- H.query () pgVersion
|
||||||
return $ toInteger ver >= minimumPgVersion
|
return $ ver >= pgvNum minimumPgVersion
|
||||||
where
|
where
|
||||||
pgVersion =
|
pgVersion =
|
||||||
H.statement "SHOW server_version_num"
|
H.statement "SELECT current_setting('server_version_num')::integer"
|
||||||
HE.unit (HD.singleRow $ HD.value HD.int4) True
|
HE.unit (HD.singleRow $ HD.value HD.int4) False
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
@@ -67,7 +68,7 @@ main = do
|
|||||||
supported <- isServerVersionSupported
|
supported <- isServerVersionSupported
|
||||||
unless supported $ panic (
|
unless supported $ panic (
|
||||||
"Cannot run in this PostgreSQL version, PostgREST needs at least "
|
"Cannot run in this PostgreSQL version, PostgREST needs at least "
|
||||||
<> show minimumPgVersion)
|
<> pgvName minimumPgVersion)
|
||||||
getDbStructure (toS $ configSchema conf)
|
getDbStructure (toS $ configSchema conf)
|
||||||
|
|
||||||
forM_ (lefts [result]) $ \e -> do
|
forM_ (lefts [result]) $ \e -> do
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ module PostgREST.Config ( prettyVersion
|
|||||||
, readOptions
|
, readOptions
|
||||||
, corsPolicy
|
, corsPolicy
|
||||||
, minimumPgVersion
|
, minimumPgVersion
|
||||||
|
, PgVersion (..)
|
||||||
, AppConfig (..)
|
, AppConfig (..)
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
@@ -171,6 +172,12 @@ argParser = CmdArgs <$>
|
|||||||
help "Path to configuration file")) <*>
|
help "Path to configuration file")) <*>
|
||||||
switch (long "example-config" <> help "output an example config file")
|
switch (long "example-config" <> help "output an example config file")
|
||||||
|
|
||||||
|
|
||||||
|
data PgVersion = PgVersion {
|
||||||
|
pgvNum :: Int32
|
||||||
|
, pgvName :: Text
|
||||||
|
}
|
||||||
|
|
||||||
-- | Tells the minimum PostgreSQL version required by this version of PostgREST
|
-- | Tells the minimum PostgreSQL version required by this version of PostgREST
|
||||||
minimumPgVersion :: Integer
|
minimumPgVersion :: PgVersion
|
||||||
minimumPgVersion = 90300
|
minimumPgVersion = PgVersion 90300 "9.3"
|
||||||
|
|||||||
Reference in New Issue
Block a user