From 080abcb6957da5af2becaea6ead4fb23fcbf785b Mon Sep 17 00:00:00 2001 From: Taimoor Zaeem Date: Sun, 19 Jul 2026 14:04:48 +0500 Subject: [PATCH] chore: increase columns length in .stylish-haskell.yaml This gives the import statements more space, essentially, it collectively removes 90+ unneeded lines in the imports statements. Signed-off-by: Taimoor Zaeem --- .stylish-haskell.yaml | 2 +- nix/hsie/Main.hs | 3 +- src/library/PostgREST/ApiRequest.hs | 21 ++++------ .../PostgREST/ApiRequest/QueryParams.hs | 42 ++++++++----------- src/library/PostgREST/ApiRequest/Types.hs | 3 +- src/library/PostgREST/App.hs | 14 +++---- src/library/PostgREST/AppState.hs | 26 ++++-------- src/library/PostgREST/Auth.hs | 3 +- src/library/PostgREST/Auth/JwtCache.hs | 7 ++-- src/library/PostgREST/Config.hs | 13 +++--- src/library/PostgREST/Config/JSPath.hs | 2 +- src/library/PostgREST/Error.hs | 12 ++---- src/library/PostgREST/Error/Types.hs | 3 +- src/library/PostgREST/Listener.hs | 4 +- src/library/PostgREST/Logger.hs | 6 +-- src/library/PostgREST/MainTx.hs | 17 +++----- src/library/PostgREST/Plan.hs | 27 +++++------- src/library/PostgREST/Plan/MutatePlan.hs | 6 +-- src/library/PostgREST/Plan/Negotiate.hs | 3 +- src/library/PostgREST/Plan/ReadPlan.hs | 10 ++--- src/library/PostgREST/Plan/Types.hs | 5 +-- src/library/PostgREST/Query.hs | 9 ++-- src/library/PostgREST/Query/PreQuery.hs | 6 +-- src/library/PostgREST/Query/QueryBuilder.hs | 3 +- src/library/PostgREST/Query/SqlFragment.hs | 38 +++++++---------- src/library/PostgREST/Query/Statements.hs | 3 +- src/library/PostgREST/RangeQuery.hs | 2 +- src/library/PostgREST/Response.hs | 18 +++----- src/library/PostgREST/Response/OpenAPI.hs | 9 ++-- src/library/PostgREST/SchemaCache.hs | 23 ++++------ .../PostgREST/SchemaCache/Relationship.hs | 4 +- src/library/PostgREST/SchemaCache/Routine.hs | 3 +- src/library/PostgREST/SchemaCache/Table.hs | 3 +- test/observability/ObsHelper.hs | 3 +- test/observability/Observation/MetricsSpec.hs | 3 +- test/spec/Main.hs | 3 +- test/spec/SpecHelper.hs | 11 ++--- 37 files changed, 137 insertions(+), 233 deletions(-) diff --git a/.stylish-haskell.yaml b/.stylish-haskell.yaml index 3bdbfc88c..fffa675c9 100644 --- a/.stylish-haskell.yaml +++ b/.stylish-haskell.yaml @@ -200,7 +200,7 @@ steps: # A common setting is the number of columns (parts of) code will be wrapped # to. Different steps take this into account. Default: 80. -columns: 70 +columns: 80 # By default, line endings are converted according to the OS. You can override # preferred format here. diff --git a/nix/hsie/Main.hs b/nix/hsie/Main.hs index 7b2efa406..e1217e3cb 100644 --- a/nix/hsie/Main.hs +++ b/nix/hsie/Main.hs @@ -37,8 +37,7 @@ import Data.Text (Text) import GHC.Driver.Errors.Types (GhcMessage) import GHC.Generics (Generic) import GHC.Hs.Extension (GhcPs) -import GHC.Types.Error (Messages, defaultDiagnosticOpts, - getMessages) +import GHC.Types.Error (Messages, defaultDiagnosticOpts, getMessages) import GHC.Types.Name.Occurrence (occNameString) import GHC.Types.Name.Reader (rdrNameOcc) import GHC.Unit.Module (moduleNameString) diff --git a/src/library/PostgREST/ApiRequest.hs b/src/library/PostgREST/ApiRequest.hs index b3434887d..eb09e6e6e 100644 --- a/src/library/PostgREST/ApiRequest.hs +++ b/src/library/PostgREST/ApiRequest.hs @@ -20,8 +20,7 @@ import qualified Data.Text.Encoding as T import Data.List (lookup) import Data.Ranged.Ranges (emptyRange, rangeIntersection, rangeIsEmpty) -import Network.HTTP.Types.Header (RequestHeaders, - hAuthorization, hCookie) +import Network.HTTP.Types.Header (RequestHeaders, hAuthorization, hCookie) import Network.Wai (Request (..)) import Network.Wai.Middleware.HttpAuth (extractBearerAuth) import Network.Wai.Parse (parseHttpAccept) @@ -30,21 +29,17 @@ import Web.Cookie (parseCookies) import PostgREST.ApiRequest.Payload (getPayload) import PostgREST.ApiRequest.QueryParams (QueryParams (..)) import PostgREST.ApiRequest.Types (Action (..), DbAction (..), - InvokeMethod (..), - Mutation (..), Payload (..), - RequestBody, Resource (..)) -import PostgREST.Config (AppConfig (..), - OpenAPIMode (..)) + InvokeMethod (..), Mutation (..), + Payload (..), RequestBody, + Resource (..)) +import PostgREST.Config (AppConfig (..), OpenAPIMode (..)) import PostgREST.Config.Database (TimezoneNames) -import PostgREST.Error (ApiRequestError (..), - RangeError (..)) +import PostgREST.Error (ApiRequestError (..), RangeError (..)) import PostgREST.MediaType (MediaType (..)) import PostgREST.RangeQuery (NonnegRange, allRange, - convertToLimitZeroRange, - hasLimitZero, + convertToLimitZeroRange, hasLimitZero, rangeRequested) -import PostgREST.SchemaCache.Identifiers (FieldName, - QualifiedIdentifier (..), +import PostgREST.SchemaCache.Identifiers (FieldName, QualifiedIdentifier (..), Schema) import qualified PostgREST.ApiRequest.Preferences as Preferences diff --git a/src/library/PostgREST/ApiRequest/QueryParams.hs b/src/library/PostgREST/ApiRequest/QueryParams.hs index 688e82a52..79c8844c0 100644 --- a/src/library/PostgREST/ApiRequest/QueryParams.hs +++ b/src/library/PostgREST/ApiRequest/QueryParams.hs @@ -39,34 +39,28 @@ import Data.List (init, last) import Data.Ranged.Boundaries (Boundary (..)) import Data.Ranged.Ranges (Range (..)) import Data.Tree (Tree (..)) -import Text.Parsec.Error (errorMessages, - showErrorMessages) -import Text.ParserCombinators.Parsec (GenParser, ParseError, Parser, - anyChar, between, char, choice, - digit, eof, errorPos, letter, - lookAhead, many1, noneOf, - notFollowedBy, oneOf, - optionMaybe, sepBy, sepBy1, - string, try, ()) +import Text.Parsec.Error (errorMessages, showErrorMessages) +import Text.ParserCombinators.Parsec (GenParser, ParseError, Parser, anyChar, + between, char, choice, digit, eof, + errorPos, letter, lookAhead, many1, + noneOf, notFollowedBy, oneOf, optionMaybe, + sepBy, sepBy1, string, try, ()) -import PostgREST.RangeQuery (NonnegRange, allRange, - rangeGeq, rangeLimit, - rangeOffset, restrictRange) +import PostgREST.RangeQuery (NonnegRange, allRange, rangeGeq, + rangeLimit, rangeOffset, + restrictRange) import PostgREST.SchemaCache.Identifiers (FieldName) -import PostgREST.ApiRequest.Types (AggregateFunction (..), - EmbedParam (..), EmbedPath, Field, - Filter (..), FtsOperator (..), - Hint, IsVal (..), JoinType (..), - JsonOperand (..), - JsonOperation (..), JsonPath, - ListVal, LogicOperator (..), - LogicTree (..), OpExpr (..), - OpQuantifier (..), Operation (..), - OrderDirection (..), +import PostgREST.ApiRequest.Types (AggregateFunction (..), EmbedParam (..), + EmbedPath, Field, Filter (..), + FtsOperator (..), Hint, IsVal (..), + JoinType (..), JsonOperand (..), + JsonOperation (..), JsonPath, ListVal, + LogicOperator (..), LogicTree (..), + OpExpr (..), OpQuantifier (..), + Operation (..), OrderDirection (..), OrderNulls (..), OrderTerm (..), - QuantOperator (..), - SelectItem (..), + QuantOperator (..), SelectItem (..), SimpleOperator (..), SingleVal) import PostgREST.Error (QPError (..)) diff --git a/src/library/PostgREST/ApiRequest/Types.hs b/src/library/PostgREST/ApiRequest/Types.hs index bf3ddd9b0..77f016c47 100644 --- a/src/library/PostgREST/ApiRequest/Types.hs +++ b/src/library/PostgREST/ApiRequest/Types.hs @@ -42,8 +42,7 @@ module PostgREST.ApiRequest.Types import qualified Data.ByteString.Lazy as LBS import qualified Data.Set as S -import PostgREST.SchemaCache.Identifiers (FieldName, - QualifiedIdentifier (..), +import PostgREST.SchemaCache.Identifiers (FieldName, QualifiedIdentifier (..), Schema) import Protolude diff --git a/src/library/PostgREST/App.hs b/src/library/PostgREST/App.hs index 40620aea3..351f8cfe6 100644 --- a/src/library/PostgREST/App.hs +++ b/src/library/PostgREST/App.hs @@ -27,12 +27,10 @@ import System.IO.Error (ioeGetErrorType) import Control.Monad.Except (liftEither) import Data.Either.Combinators (mapLeft, whenLeft) -import Data.IORef (atomicWriteIORef, newIORef, - readIORef) +import Data.IORef (atomicWriteIORef, newIORef, readIORef) import Data.String (IsString (..), String) -import Network.Wai.Handler.Warp (defaultSettings, setBeforeMainLoop, - setHost, setOnException, setPort, - setServerName) +import Network.Wai.Handler.Warp (defaultSettings, setBeforeMainLoop, setHost, + setOnException, setPort, setServerName) import qualified Data.Text.Encoding as T import qualified Network.Wai as Wai @@ -59,8 +57,7 @@ import PostgREST.Config (AppConfig (..)) import PostgREST.Error (Error) import PostgREST.Network (resolveSocketToAddress) import PostgREST.Observation (Observation (..)) -import PostgREST.Response.Performance (ServerTiming (..), - serverTimingHeader) +import PostgREST.Response.Performance (ServerTiming (..), serverTimingHeader) import PostgREST.SchemaCache (SchemaCache (..)) import PostgREST.TimeIt (timeItT) import PostgREST.Version (docsVersion, prettyVersion) @@ -68,8 +65,7 @@ import PostgREST.Version (docsVersion, prettyVersion) import Control.Monad.Writer import qualified Data.ByteString.Char8 as BS import qualified Data.List as L -import Data.Streaming.Network (HostPreference, - bindPortGenEx, +import Data.Streaming.Network (HostPreference, bindPortGenEx, bindPortTCP) import qualified Data.Text as T import qualified Network.HTTP.Types as HTTP diff --git a/src/library/PostgREST/AppState.hs b/src/library/PostgREST/AppState.hs index 4336ed310..d7210eb49 100644 --- a/src/library/PostgREST/AppState.hs +++ b/src/library/PostgREST/AppState.hs @@ -44,30 +44,22 @@ import PostgREST.Observation import PostgREST.TimeIt (timeItT) import PostgREST.Version (prettyVersion) -import Control.AutoUpdate (defaultUpdateSettings, mkAutoUpdate, - updateAction) +import Control.AutoUpdate (defaultUpdateSettings, mkAutoUpdate, updateAction) import Control.Retry (RetryPolicy, RetryStatus (..), capDelay, - exponentialBackoff, retrying, - rsPreviousDelay) -import Data.IORef (IORef, atomicWriteIORef, newIORef, - readIORef) + exponentialBackoff, retrying, rsPreviousDelay) +import Data.IORef (IORef, atomicWriteIORef, newIORef, readIORef) import Data.Time.Clock (UTCTime, getCurrentTime) -import Control.Concurrent.STM (TMVar, newEmptyTMVarIO, - putTMVar, readTMVar, - tryReadTMVar, tryTakeTMVar) +import Control.Concurrent.STM (TMVar, newEmptyTMVarIO, putTMVar, + readTMVar, tryReadTMVar, tryTakeTMVar) import PostgREST.Auth.JwtCache (JwtCacheState, update) -import PostgREST.Config (AppConfig (..), - readAppConfig, +import PostgREST.Config (AppConfig (..), readAppConfig, toConnectionSettings) -import PostgREST.Config.Database (queryDbSettings, - queryPgVersion, +import PostgREST.Config.Database (queryDbSettings, queryPgVersion, queryRoleSettings) -import PostgREST.Config.PgVersion (PgVersion (..), - minimumPgVersion) +import PostgREST.Config.PgVersion (PgVersion (..), minimumPgVersion) import PostgREST.Debounce (makeDebouncer) -import PostgREST.SchemaCache (SchemaCache (..), - querySchemaCache, +import PostgREST.SchemaCache (SchemaCache (..), querySchemaCache, showSummary) import PostgREST.SchemaCache.Identifiers (quoteQi) diff --git a/src/library/PostgREST/Auth.hs b/src/library/PostgREST/Auth.hs index 9d332c282..01544fa81 100644 --- a/src/library/PostgREST/Auth.hs +++ b/src/library/PostgREST/Auth.hs @@ -15,8 +15,7 @@ module PostgREST.Auth ( getAuthResult ) where -import PostgREST.AppState (AppState, getConfig, getJwtCacheState, - getTime) +import PostgREST.AppState (AppState, getConfig, getJwtCacheState, getTime) import PostgREST.Auth.Jwt (parseClaims) import PostgREST.Auth.JwtCache (lookupJwtCache) import PostgREST.Auth.Types (AuthResult) diff --git a/src/library/PostgREST/Auth/JwtCache.hs b/src/library/PostgREST/Auth/JwtCache.hs index 389043add..a1b088847 100644 --- a/src/library/PostgREST/Auth/JwtCache.hs +++ b/src/library/PostgREST/Auth/JwtCache.hs @@ -24,13 +24,12 @@ import qualified Data.Aeson.KeyMap as KM import PostgREST.Error (Error (..), JwtError (JwtSecretMissing)) -import Control.Concurrent.STM (newTVarIO, readTVar, - writeTVar) +import Control.Concurrent.STM (newTVarIO, readTVar, writeTVar) import Control.Concurrent.STM.TVar (TVar) import Control.Monad.Error.Class (liftEither) import Data.ByteString hiding (all, init) -import Data.IORef (IORef, newIORef, - readIORef, writeIORef) +import Data.IORef (IORef, newIORef, readIORef, + writeIORef) import Jose.Jwk (JwkSet) import PostgREST.Auth.Jwt (parseAndDecodeClaims) import PostgREST.Cache.Sieve (alwaysValid) diff --git a/src/library/PostgREST/Config.hs b/src/library/PostgREST/Config.hs index b5f09e192..146ebef44 100644 --- a/src/library/PostgREST/Config.hs +++ b/src/library/PostgREST/Config.hs @@ -60,15 +60,12 @@ import Numeric (readOct, showOct) import System.Environment (getEnvironment) import System.Posix.Types (FileMode) -import PostgREST.Config.Database (RoleIsolationLvl, - RoleSettings) -import PostgREST.Config.JSPath (JSPath (..), - defaultRoleJSPathKey, +import PostgREST.Config.Database (RoleIsolationLvl, RoleSettings) +import PostgREST.Config.JSPath (JSPath (..), defaultRoleJSPathKey, dumpJSPath, pRoleClaimKey) -import PostgREST.Config.Proxy (Proxy (..), - isMalformedProxyUri, toURI) -import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..), - toQi) +import PostgREST.Config.Proxy (Proxy (..), isMalformedProxyUri, + toURI) +import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..), toQi) import PostgREST.Version (prettyVersion) import Protolude hiding (Proxy, toList) diff --git a/src/library/PostgREST/Config/JSPath.hs b/src/library/PostgREST/Config/JSPath.hs index 2b3eeafcb..06bc8bec0 100644 --- a/src/library/PostgREST/Config/JSPath.hs +++ b/src/library/PostgREST/Config/JSPath.hs @@ -47,7 +47,7 @@ dumpJSPath (JSPath query) = (escapeDollarChar . escapeDoubleQuotes) jsPathDump -- The result of JSON Path query is a Vector, we select the first -- string element as the role. evaluateJSPath :: Maybe JSON.Value -> JSPath -> Maybe JSON.Value -evaluateJSPath Nothing _ = Nothing +evaluateJSPath Nothing _ = Nothing evaluateJSPath (Just json) (JSPath query) = JSP.queryQQ query json V.!? 0 -- Used for the config value "role-claim-key" diff --git a/src/library/PostgREST/Error.hs b/src/library/PostgREST/Error.hs index eb746156d..fe2c2de5b 100644 --- a/src/library/PostgREST/Error.hs +++ b/src/library/PostgREST/Error.hs @@ -46,14 +46,10 @@ import qualified PostgREST.MediaType as MediaType import PostgREST.Config (Verbosity (..)) import PostgREST.SchemaCache (SchemaCache (SchemaCache, dbTablesFuzzyIndex)) -import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..), - Schema) -import PostgREST.SchemaCache.Relationship (Cardinality (..), - Junction (..), - Relationship (..), - RelationshipsMap) -import PostgREST.SchemaCache.Routine (Routine (..), - RoutineParam (..)) +import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..), Schema) +import PostgREST.SchemaCache.Relationship (Cardinality (..), Junction (..), + Relationship (..), RelationshipsMap) +import PostgREST.SchemaCache.Routine (Routine (..), RoutineParam (..)) import PostgREST.Error.Types diff --git a/src/library/PostgREST/Error/Types.hs b/src/library/PostgREST/Error/Types.hs index 6129590e6..31e66e718 100644 --- a/src/library/PostgREST/Error/Types.hs +++ b/src/library/PostgREST/Error/Types.hs @@ -22,8 +22,7 @@ import qualified Hasql.Pool as SQL import PostgREST.MediaType (MediaType (..)) import PostgREST.SchemaCache (SchemaCache (..)) import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..)) -import PostgREST.SchemaCache.Relationship (Relationship (..), - RelationshipsMap) +import PostgREST.SchemaCache.Relationship (Relationship (..), RelationshipsMap) import PostgREST.SchemaCache.Routine (Routine (..)) import Protolude diff --git a/src/library/PostgREST/Listener.hs b/src/library/PostgREST/Listener.hs index ba4d202d6..40df04cb3 100644 --- a/src/library/PostgREST/Listener.hs +++ b/src/library/PostgREST/Listener.hs @@ -18,8 +18,8 @@ import qualified PostgREST.Config as Config import Control.Arrow ((&&&)) import Data.Bitraversable (bisequence) import Data.Either.Combinators (whenRight) -import Data.IORef (IORef, newIORef, - readIORef, writeIORef) +import Data.IORef (IORef, newIORef, readIORef, + writeIORef) import qualified Data.Text as T import qualified Database.PostgreSQL.LibPQ as LibPQ import qualified Hasql.Session as SQL diff --git a/src/library/PostgREST/Logger.hs b/src/library/PostgREST/Logger.hs index 3d3af8176..42a23e43e 100644 --- a/src/library/PostgREST/Logger.hs +++ b/src/library/PostgREST/Logger.hs @@ -13,8 +13,7 @@ module PostgREST.Logger ) where import Control.AutoUpdate (defaultUpdateSettings, - mkAutoUpdate, - updateAction) + mkAutoUpdate, updateAction) import qualified Data.ByteString.Char8 as BS import qualified Data.Text.Encoding as T import qualified Hasql.Decoders as HD @@ -22,8 +21,7 @@ import qualified Hasql.DynamicStatements.Snippet as SQL hiding (sql) import qualified Hasql.DynamicStatements.Statement as SQL import qualified Hasql.Statement as SQL -import Data.Time (ZonedTime, defaultTimeLocale, formatTime, - getZonedTime) +import Data.Time (ZonedTime, defaultTimeLocale, formatTime, getZonedTime) import Network.HTTP.Types.Status (Status, status400, status500) diff --git a/src/library/PostgREST/MainTx.hs b/src/library/PostgREST/MainTx.hs index 4a6d753ae..30f02d441 100644 --- a/src/library/PostgREST/MainTx.hs +++ b/src/library/PostgREST/MainTx.hs @@ -16,8 +16,7 @@ module PostgREST.MainTx import Control.Lens ((^?)) import Control.Monad.Extra (whenJust) import qualified Data.Aeson.Lens as L -import qualified Data.ByteString as BS hiding - (break) +import qualified Data.ByteString as BS hiding (break) import qualified Data.ByteString.Char8 as BS import qualified Data.HashMap.Strict as HM import qualified Data.Set as S @@ -32,21 +31,17 @@ import qualified PostgREST.SchemaCache as SchemaCache import PostgREST.ApiRequest (ApiRequest (..)) -import PostgREST.ApiRequest.Preferences (PreferCount (..), - PreferHandling (..), +import PostgREST.ApiRequest.Preferences (PreferCount (..), PreferHandling (..), PreferMaxAffected (..), PreferTransaction (..), Preferences (..)) import PostgREST.ApiRequest.Types (Mutation (..)) import PostgREST.Auth.Types (AuthResult (..)) -import PostgREST.Config (AppConfig (..), - OpenAPIMode (..)) +import PostgREST.Config (AppConfig (..), OpenAPIMode (..)) import PostgREST.Error (Error) import PostgREST.MediaType (MediaType (..)) -import PostgREST.Plan (ActionPlan (..), - CrudPlan (..), - DbActionPlan (..), - InfoPlan (..), +import PostgREST.Plan (ActionPlan (..), CrudPlan (..), + DbActionPlan (..), InfoPlan (..), InspectPlan (..)) import PostgREST.Query (MainQuery (..)) import PostgREST.SchemaCache (SchemaCache (..)) @@ -110,7 +105,7 @@ planTxMode (MayUseDb x) = ipTxmode x planIsoLvl :: AppConfig -> ByteString -> DbActionPlan -> SQL.IsolationLevel planIsoLvl AppConfig{configRoleIsoLvl} role actPlan = case actPlan of DbCrud _ CallReadPlan{crProc} -> fromMaybe roleIsoLvl $ pdIsoLvl crProc - _ -> roleIsoLvl + _ -> roleIsoLvl where roleIsoLvl = HM.findWithDefault SQL.ReadCommitted role configRoleIsoLvl diff --git a/src/library/PostgREST/Plan.hs b/src/library/PostgREST/Plan.hs index 8a91fa959..4cec7f060 100644 --- a/src/library/PostgREST/Plan.hs +++ b/src/library/PostgREST/Plan.hs @@ -41,8 +41,7 @@ import Data.Tree (Tree (..)) import PostgREST.ApiRequest (ApiRequest (..)) import PostgREST.Config (AppConfig (..)) -import PostgREST.Error (ApiRequestError (..), - Error (..), +import PostgREST.Error (ApiRequestError (..), Error (..), SchemaCacheError (..)) import PostgREST.MediaType (MediaType (..)) import PostgREST.Plan.Negotiate (negotiateContent) @@ -52,25 +51,19 @@ import PostgREST.RangeQuery (NonnegRange, allRange, restrictRange) import PostgREST.SchemaCache (SchemaCache (..)) import PostgREST.SchemaCache.Identifiers (FieldName, - QualifiedIdentifier (..), - Schema) -import PostgREST.SchemaCache.Relationship (Cardinality (..), - Junction (..), + QualifiedIdentifier (..), Schema) +import PostgREST.SchemaCache.Relationship (Cardinality (..), Junction (..), Relationship (..), - RelationshipsMap, - relIsToOne) + RelationshipsMap, relIsToOne) import PostgREST.SchemaCache.Representations (DataRepresentation (..), RepresentationsMap) -import PostgREST.SchemaCache.Routine (MediaHandler (..), - Routine (..), - RoutineMap, - RoutineParam (..), +import PostgREST.SchemaCache.Routine (MediaHandler (..), Routine (..), + RoutineMap, RoutineParam (..), funcReturnsScalar, funcReturnsSetOfScalar, funcReturnsSingle) import PostgREST.SchemaCache.Table (Column (..), Table (..), - TablesMap, - tableColumnsList, + TablesMap, tableColumnsList, tablePKCols) import PostgREST.ApiRequest.Preferences @@ -463,7 +456,7 @@ addAliases = Right . fmap addAliasToPlan isJsonKeyPath _ = False isTransformPath CoercibleField{cfTransform=(Just _), cfName=_} = True - isTransformPath _ = False + isTransformPath _ = False lastJsonKey CoercibleField{cfName=fieldName, cfJsonPath=jsonPath} = case jOp <$> lastMay jsonPath of @@ -570,7 +563,7 @@ addRels schema action allRels parentNode (Node rPlan@ReadPlan{relName,relHint,re -- we use the table name as an alias so findRel can find the right relationship. ActDb (ActRelationMut _ _) -> rPlan{from=newFrom, fromAlias=newAlias} ActDb (ActRoutine _ _) -> rPlan{from=newFrom, fromAlias=newAlias} - _ -> rPlan + _ -> rPlan in Node newReadPlan <$> updateForest (Just $ Node newReadPlan forest) where @@ -844,7 +837,7 @@ findTable :: QualifiedIdentifier -> SchemaCache -> Either Error QualifiedIdentif findTable qi@QualifiedIdentifier{..} sc@SchemaCache{dbTables} = case HM.lookup qi dbTables of Nothing -> Left $ SchemaCacheErr $ TableNotFound qiSchema qiName sc - Just _ -> Right qi + Just _ -> Right qi addFilters :: ResolverContext -> ApiRequest -> Bool -> ReadPlanTree -> Either Error ReadPlanTree addFilters ctx ApiRequest{..} useTargetNames rReq = diff --git a/src/library/PostgREST/Plan/MutatePlan.hs b/src/library/PostgREST/Plan/MutatePlan.hs index 56f631650..bea88df4b 100644 --- a/src/library/PostgREST/Plan/MutatePlan.hs +++ b/src/library/PostgREST/Plan/MutatePlan.hs @@ -6,10 +6,8 @@ where import qualified Data.ByteString.Lazy as LBS import PostgREST.ApiRequest.Preferences (PreferResolution) -import PostgREST.Plan.Types (CoercibleField, - CoercibleLogicTree) -import PostgREST.SchemaCache.Identifiers (FieldName, - QualifiedIdentifier) +import PostgREST.Plan.Types (CoercibleField, CoercibleLogicTree) +import PostgREST.SchemaCache.Identifiers (FieldName, QualifiedIdentifier) import Protolude diff --git a/src/library/PostgREST/Plan/Negotiate.hs b/src/library/PostgREST/Plan/Negotiate.hs index 3224b4c74..f69b8fe1c 100644 --- a/src/library/PostgREST/Plan/Negotiate.hs +++ b/src/library/PostgREST/Plan/Negotiate.hs @@ -18,8 +18,7 @@ import PostgREST.Error (ApiRequestError (..)) import PostgREST.MediaType (MediaType (..)) import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..), RelIdentifier (..)) -import PostgREST.SchemaCache.Routine (MediaHandler (..), - MediaHandlerMap, +import PostgREST.SchemaCache.Routine (MediaHandler (..), MediaHandlerMap, ResolvedHandler) import PostgREST.ApiRequest.Preferences diff --git a/src/library/PostgREST/Plan/ReadPlan.hs b/src/library/PostgREST/Plan/ReadPlan.hs index 1c30d36d4..d5c94f1d1 100644 --- a/src/library/PostgREST/Plan/ReadPlan.hs +++ b/src/library/PostgREST/Plan/ReadPlan.hs @@ -7,16 +7,14 @@ module PostgREST.Plan.ReadPlan import Data.Tree (Tree (..)) -import PostgREST.ApiRequest.Types (Alias, Depth, Hint, - JoinType, NodeName) +import PostgREST.ApiRequest.Types (Alias, Depth, Hint, JoinType, + NodeName) import PostgREST.Plan.Types (CoercibleLogicTree, CoercibleOrderTerm, CoercibleSelectField (..), - RelSelectField (..), - SpreadType (..)) + RelSelectField (..), SpreadType (..)) import PostgREST.RangeQuery (NonnegRange) -import PostgREST.SchemaCache.Identifiers (FieldName, - QualifiedIdentifier) +import PostgREST.SchemaCache.Identifiers (FieldName, QualifiedIdentifier) import PostgREST.SchemaCache.Relationship (Relationship) diff --git a/src/library/PostgREST/Plan/Types.hs b/src/library/PostgREST/Plan/Types.hs index f479960bd..bb161c13b 100644 --- a/src/library/PostgREST/Plan/Types.hs +++ b/src/library/PostgREST/Plan/Types.hs @@ -13,9 +13,8 @@ module PostgREST.Plan.Types , SpreadType(..) ) where -import PostgREST.ApiRequest.Types (AggregateFunction, Alias, Cast, - Field, JsonPath, Language, - LogicOperator, OpExpr, +import PostgREST.ApiRequest.Types (AggregateFunction, Alias, Cast, Field, + JsonPath, Language, LogicOperator, OpExpr, OrderDirection, OrderNulls) import PostgREST.SchemaCache.Identifiers (FieldName) diff --git a/src/library/PostgREST/Query.hs b/src/library/PostgREST/Query.hs index b47abd896..4eddae0ec 100644 --- a/src/library/PostgREST/Query.hs +++ b/src/library/PostgREST/Query.hs @@ -19,14 +19,11 @@ import qualified PostgREST.Query.Statements as Statements import PostgREST.ApiRequest (ApiRequest (..)) -import PostgREST.ApiRequest.Preferences (Preferences (..), - shouldExplainCount) +import PostgREST.ApiRequest.Preferences (Preferences (..), shouldExplainCount) import PostgREST.Auth.Types (AuthResult (..)) import PostgREST.Config (AppConfig (..)) -import PostgREST.Plan (ActionPlan (..), - CrudPlan (..), - DbActionPlan (..), - InspectPlan (..)) +import PostgREST.Plan (ActionPlan (..), CrudPlan (..), + DbActionPlan (..), InspectPlan (..)) import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..)) import Protolude hiding (Handler) diff --git a/src/library/PostgREST/Query/PreQuery.hs b/src/library/PostgREST/Query/PreQuery.hs index bb931ffb2..59cd4cc79 100644 --- a/src/library/PostgREST/Query/PreQuery.hs +++ b/src/library/PostgREST/Query/PreQuery.hs @@ -18,12 +18,10 @@ import qualified Hasql.DynamicStatements.Snippet as SQL hiding (sql) import PostgREST.ApiRequest (ApiRequest (..)) -import PostgREST.ApiRequest.Preferences (PreferTimezone (..), - Preferences (..)) +import PostgREST.ApiRequest.Preferences (PreferTimezone (..), Preferences (..)) import PostgREST.Auth.Types (AuthResult (..)) import PostgREST.Config (AppConfig (..)) -import PostgREST.Plan (CrudPlan (..), - DbActionPlan (..)) +import PostgREST.Plan (CrudPlan (..), DbActionPlan (..)) import PostgREST.Query.SqlFragment (escapeIdentList, fromQi, intercalateSnippet, setConfigWithConstantName, diff --git a/src/library/PostgREST/Query/QueryBuilder.hs b/src/library/PostgREST/Query/QueryBuilder.hs index f84a5e2d7..2add82f2e 100644 --- a/src/library/PostgREST/Query/QueryBuilder.hs +++ b/src/library/PostgREST/Query/QueryBuilder.hs @@ -29,8 +29,7 @@ import Data.Tree (Tree (..)) import PostgREST.ApiRequest.Preferences (PreferResolution (..)) import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..)) -import PostgREST.SchemaCache.Relationship (Cardinality (..), - Junction (..), +import PostgREST.SchemaCache.Relationship (Cardinality (..), Junction (..), Relationship (..)) import PostgREST.SchemaCache.Routine (RoutineParam (..)) diff --git a/src/library/PostgREST/Query/SqlFragment.hs b/src/library/PostgREST/Query/SqlFragment.hs index 75cb29821..559481b95 100644 --- a/src/library/PostgREST/Query/SqlFragment.hs +++ b/src/library/PostgREST/Query/SqlFragment.hs @@ -60,20 +60,13 @@ import Control.Arrow ((***)) import Data.Foldable (foldr1) import NeatInterpolation (trimming) -import PostgREST.ApiRequest.Types (AggregateFunction (..), - Alias, Cast, - FtsOperator (..), - IsVal (..), - JsonOperand (..), - JsonOperation (..), - JsonPath, - LogicOperator (..), - OpExpr (..), - OpQuantifier (..), - Operation (..), - OrderDirection (..), - OrderNulls (..), - QuantOperator (..), +import PostgREST.ApiRequest.Types (AggregateFunction (..), Alias, Cast, + FtsOperator (..), IsVal (..), + JsonOperand (..), JsonOperation (..), + JsonPath, LogicOperator (..), + OpExpr (..), OpQuantifier (..), + Operation (..), OrderDirection (..), + OrderNulls (..), QuantOperator (..), SimpleOperator (..)) import PostgREST.MediaType (MTVndPlanFormat (..), MTVndPlanOption (..)) @@ -85,16 +78,13 @@ import PostgREST.Plan.Types (CoercibleField (..), CoercibleSelectField (..), RelSelectField (..), SpreadSelectField (..), - ToTsVector (..), - unknownField) -import PostgREST.RangeQuery (NonnegRange, allRange, - rangeLimit, rangeOffset) -import PostgREST.SchemaCache.Identifiers (FieldName, - QualifiedIdentifier (..), - RelIdentifier (..), - escapeIdent, trimNullChars) -import PostgREST.SchemaCache.Routine (MediaHandler (..), - Routine (..), + ToTsVector (..), unknownField) +import PostgREST.RangeQuery (NonnegRange, allRange, rangeLimit, + rangeOffset) +import PostgREST.SchemaCache.Identifiers (FieldName, QualifiedIdentifier (..), + RelIdentifier (..), escapeIdent, + trimNullChars) +import PostgREST.SchemaCache.Routine (MediaHandler (..), Routine (..), funcReturnsScalar, funcReturnsSetOfScalar, funcReturnsSingle, diff --git a/src/library/PostgREST/Query/Statements.hs b/src/library/PostgREST/Query/Statements.hs index 9dc967fd4..d594ea4fa 100644 --- a/src/library/PostgREST/Query/Statements.hs +++ b/src/library/PostgREST/Query/Statements.hs @@ -13,8 +13,7 @@ module PostgREST.Query.Statements import qualified Hasql.DynamicStatements.Snippet as SQL import PostgREST.ApiRequest.Preferences -import PostgREST.MediaType (MTVndPlanFormat (..), - MediaType (..)) +import PostgREST.MediaType (MTVndPlanFormat (..), MediaType (..)) import PostgREST.Plan.CallPlan import PostgREST.Plan.MutatePlan as MTPlan import PostgREST.Plan.ReadPlan diff --git a/src/library/PostgREST/RangeQuery.hs b/src/library/PostgREST/RangeQuery.hs index a27a1af5c..d2282c3d0 100644 --- a/src/library/PostgREST/RangeQuery.hs +++ b/src/library/PostgREST/RangeQuery.hs @@ -59,7 +59,7 @@ rangeLimit :: NonnegRange -> Maybe Integer rangeLimit range = case [rangeLower range, rangeUpper range] of [BoundaryBelow lower, BoundaryAbove upper] -> Just (1 + upper - lower) - _ -> Nothing + _ -> Nothing rangeOffset :: NonnegRange -> Integer rangeOffset range = diff --git a/src/library/PostgREST/Response.hs b/src/library/PostgREST/Response.hs index 617800a05..89f431a98 100644 --- a/src/library/PostgREST/Response.hs +++ b/src/library/PostgREST/Response.hs @@ -27,26 +27,20 @@ import qualified PostgREST.Response.OpenAPI as OpenAPI import PostgREST.ApiRequest (ApiRequest (..)) import PostgREST.ApiRequest.Preferences (PreferRepresentation (..), PreferResolution (..), - Preferences (..), - prefAppliedHeader, + Preferences (..), prefAppliedHeader, shouldCount) import PostgREST.ApiRequest.QueryParams (QueryParams (..)) -import PostgREST.ApiRequest.Types (InvokeMethod (..), - Mutation (..)) +import PostgREST.ApiRequest.Types (InvokeMethod (..), Mutation (..)) import PostgREST.Config (AppConfig (..)) -import PostgREST.MainTx (DbResult (..), - ResultSet (..)) +import PostgREST.MainTx (DbResult (..), ResultSet (..)) import PostgREST.MediaType (MediaType (..)) -import PostgREST.Plan (CrudPlan (..), - InfoPlan (..), +import PostgREST.Plan (CrudPlan (..), InfoPlan (..), InspectPlan (..)) import PostgREST.Plan.MutatePlan (MutatePlan (..)) import PostgREST.Response.GucHeader (GucHeader, unwrapGucHeader) import PostgREST.SchemaCache (SchemaCache (..)) -import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..), - Schema) -import PostgREST.SchemaCache.Routine (FuncVolatility (..), - Routine (..)) +import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..), Schema) +import PostgREST.SchemaCache.Routine (FuncVolatility (..), Routine (..)) import PostgREST.SchemaCache.Table (Table (..)) import qualified PostgREST.SchemaCache.Routine as Routine diff --git a/src/library/PostgREST/Response/OpenAPI.hs b/src/library/PostgREST/Response/OpenAPI.hs index 6f90f7ad5..c7cb2748b 100644 --- a/src/library/PostgREST/Response/OpenAPI.hs +++ b/src/library/PostgREST/Response/OpenAPI.hs @@ -29,14 +29,11 @@ import PostgREST.MediaType import PostgREST.Network (escapeHostName) import PostgREST.SchemaCache (SchemaCache (..)) import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..)) -import PostgREST.SchemaCache.Relationship (Cardinality (..), - Relationship (..), +import PostgREST.SchemaCache.Relationship (Cardinality (..), Relationship (..), RelationshipsMap) -import PostgREST.SchemaCache.Routine (FuncVolatility (..), - Routine (..), +import PostgREST.SchemaCache.Routine (FuncVolatility (..), Routine (..), RoutineParam (..)) -import PostgREST.SchemaCache.Table (Column (..), Table (..), - TablesMap, +import PostgREST.SchemaCache.Table (Column (..), Table (..), TablesMap, tableColumnsList) import Protolude hiding (Proxy, get) diff --git a/src/library/PostgREST/SchemaCache.hs b/src/library/PostgREST/SchemaCache.hs index a598a8223..31aaf6e07 100644 --- a/src/library/PostgREST/SchemaCache.hs +++ b/src/library/PostgREST/SchemaCache.hs @@ -44,29 +44,22 @@ import qualified Hasql.Transaction as SQL import Data.Functor.Contravariant ((>$<)) import NeatInterpolation (trimming) -import PostgREST.Config (AppConfig (..), - LogLevel (..)) -import PostgREST.Config.Database (TimezoneNames, - toIsolationLevel) +import PostgREST.Config (AppConfig (..), LogLevel (..)) +import PostgREST.Config.Database (TimezoneNames, toIsolationLevel) import PostgREST.SchemaCache.Identifiers (FieldName, QualifiedIdentifier (..), - RelIdentifier (..), - Schema, escapeIdent, - isAnyElement) -import PostgREST.SchemaCache.Relationship (Cardinality (..), - Junction (..), + RelIdentifier (..), Schema, + escapeIdent, isAnyElement) +import PostgREST.SchemaCache.Relationship (Cardinality (..), Junction (..), Relationship (..), RelationshipsMap) import PostgREST.SchemaCache.Representations (DataRepresentation (..), RepresentationsMap) import PostgREST.SchemaCache.Routine (FuncVolatility (..), MediaHandler (..), - MediaHandlerMap, - PgType (..), - RetType (..), - Routine (..), - RoutineMap, - RoutineParam (..)) + MediaHandlerMap, PgType (..), + RetType (..), Routine (..), + RoutineMap, RoutineParam (..)) import PostgREST.SchemaCache.Table (Column (..), ColumnMap, Table (..), TablesMap) diff --git a/src/library/PostgREST/SchemaCache/Relationship.hs b/src/library/PostgREST/SchemaCache/Relationship.hs index f51471237..c59d936a5 100644 --- a/src/library/PostgREST/SchemaCache/Relationship.hs +++ b/src/library/PostgREST/SchemaCache/Relationship.hs @@ -12,8 +12,8 @@ module PostgREST.SchemaCache.Relationship import qualified Data.Aeson as JSON import qualified Data.HashMap.Strict as HM -import PostgREST.SchemaCache.Identifiers (FieldName, - QualifiedIdentifier, Schema) +import PostgREST.SchemaCache.Identifiers (FieldName, QualifiedIdentifier, + Schema) import Protolude diff --git a/src/library/PostgREST/SchemaCache/Routine.hs b/src/library/PostgREST/SchemaCache/Routine.hs index 081642010..6f20e892d 100644 --- a/src/library/PostgREST/SchemaCache/Routine.hs +++ b/src/library/PostgREST/SchemaCache/Routine.hs @@ -28,8 +28,7 @@ import qualified Hasql.Transaction.Sessions as SQL import qualified PostgREST.MediaType as MediaType import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..), - RelIdentifier (..), Schema, - TableName) + RelIdentifier (..), Schema, TableName) import Protolude diff --git a/src/library/PostgREST/SchemaCache/Table.hs b/src/library/PostgREST/SchemaCache/Table.hs index e2a16ee7d..ec67d6681 100644 --- a/src/library/PostgREST/SchemaCache/Table.hs +++ b/src/library/PostgREST/SchemaCache/Table.hs @@ -14,8 +14,7 @@ import qualified Data.Aeson as JSON import qualified Data.HashMap.Strict as HM import qualified Data.HashMap.Strict.InsOrd as HMI -import PostgREST.SchemaCache.Identifiers (FieldName, - QualifiedIdentifier (..), +import PostgREST.SchemaCache.Identifiers (FieldName, QualifiedIdentifier (..), Schema, TableName) import Protolude diff --git a/test/observability/ObsHelper.hs b/test/observability/ObsHelper.hs index 40454da8a..ceff04ec6 100644 --- a/test/observability/ObsHelper.hs +++ b/test/observability/ObsHelper.hs @@ -23,8 +23,7 @@ import qualified Jose.Jws as JWT import qualified Jose.Jwt as JWT import Network.HTTP.Types import qualified PostgREST.AppState as AppState -import PostgREST.Config (AppConfig (..), - LogLevel (..), +import PostgREST.Config (AppConfig (..), LogLevel (..), OpenAPIMode (..), Verbosity (..), defaultRoleJSPathKey, diff --git a/test/observability/Observation/MetricsSpec.hs b/test/observability/Observation/MetricsSpec.hs index be4414561..f1f721659 100644 --- a/test/observability/Observation/MetricsSpec.hs +++ b/test/observability/Observation/MetricsSpec.hs @@ -12,8 +12,7 @@ import Network.Wai (Application) import ObsHelper import qualified PostgREST.AppState as AppState import PostgREST.Config (AppConfig (configDbSchemas)) -import PostgREST.Metrics (ConnStats (..), - MetricsState (..), +import PostgREST.Metrics (ConnStats (..), MetricsState (..), connectionCounts) import PostgREST.Observation import Prometheus (getCounter, getVectorWith) diff --git a/test/spec/Main.hs b/test/spec/Main.hs index 975804dd5..17cf04637 100644 --- a/test/spec/Main.hs +++ b/test/spec/Main.hs @@ -9,8 +9,7 @@ import Data.Function (id) import Test.Hspec import PostgREST.App (postgrest) -import PostgREST.Config (AppConfig (..), - toConnectionSettings) +import PostgREST.Config (AppConfig (..), toConnectionSettings) import PostgREST.Config.Database (queryPgVersion) import PostgREST.SchemaCache (querySchemaCache) import Protolude hiding (toList, toS) diff --git a/test/spec/SpecHelper.hs b/test/spec/SpecHelper.hs index 1febfa0ae..7a126c5ad 100644 --- a/test/spec/SpecHelper.hs +++ b/test/spec/SpecHelper.hs @@ -24,12 +24,9 @@ import Network.Wai.Test (SResponse (simpleBody, simpleHeaders, simpleStatus import System.IO.Unsafe (unsafePerformIO) import Text.Regex.TDFA ((=~)) -import PostgREST.Config (AppConfig (..), - LogLevel (..), - OpenAPIMode (..), - Verbosity (..), - defaultRoleJSPathKey, - parseSecret) +import PostgREST.Config (AppConfig (..), LogLevel (..), + OpenAPIMode (..), Verbosity (..), + defaultRoleJSPathKey, parseSecret) import PostgREST.SchemaCache.Identifiers (QualifiedIdentifier (..)) import Data.Aeson.Lens @@ -102,7 +99,7 @@ parseServerTimingHeader (h:hs) = [name, durationText] -> case BS.split '=' durationText of [_, duration] -> (name,) <$> readMaybe (BS.unpack duration) - _ -> Nothing + _ -> Nothing _ -> Nothing validateOpenApiResponse :: [Header] -> WaiSession () ()