Skip to content

Commit

Permalink
Upgrade Ormolu to 0.7.0.0
Browse files Browse the repository at this point in the history
PR-URL: hasura/graphql-engine-mono#9284
GitOrigin-RevId: 2f2cf2ad01900a54e4bdb970205ac0ef313c7e00
  • Loading branch information
Tom Harding authored and hasura-bot committed May 24, 2023
1 parent e3df245 commit e0c0043
Show file tree
Hide file tree
Showing 598 changed files with 14,513 additions and 12,833 deletions.
306 changes: 153 additions & 153 deletions contrib/metadata-types/generated/HasuraMetadataV2.hs

Large diffs are not rendered by default.

466 changes: 233 additions & 233 deletions contrib/metadata-types/generated/HasuraMetadataV3.hs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/VERSIONS.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"cabal-install": "3.10.1.0",
"ghc": "9.2.5",
"hlint": "3.4.1",
"ormolu": "0.5.0.1"
"ormolu": "0.7.0.0"
}
2 changes: 1 addition & 1 deletion server/lib/aeson-ordered/src/Data/Aeson/Ordered.hs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ fromOrderedObject obj =
map (bimap K.fromText fromOrdered) $
Data.Aeson.Ordered.toList obj

asObject :: IsString s => Value -> Either s Object
asObject :: (IsString s) => Value -> Either s Object
asObject = \case
Object o -> Right o
_ -> Left "expecting ordered object"
Expand Down
12 changes: 6 additions & 6 deletions server/lib/api-tests/app-produce-feature-matrix/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,31 @@ data Options w = Options
{ connectionString ::
w
::: String
<?> "Postgres connection string"
<?> "Postgres connection string"
<!> "postgresql://hasura:[email protected]:65002/hasura",
output ::
w
::: FilePath
<?> "Feature matrix output file path"
<?> "Feature matrix output file path"
<!> "/tmp/feature_matrix_tool_output.html",
overrideOutputFile ::
w
::: Bool
<?> "Override output file if exists",
<?> "Override output file if exists",
createDirectory ::
w
::: Bool
<?> "Create directory if not exists",
<?> "Create directory if not exists",
-- this is just a flag, we take care of splitting the arguments ourselves.
noAsk ::
w
::: Bool
<?> "Do not ask to override output file or create a directory if missing",
<?> "Do not ask to override output file or create a directory if missing",
-- this is just a flag, we take care of splitting the arguments ourselves.
hspec ::
w
::: Bool
<?> "arguments for hspec"
<?> "arguments for hspec"
}
deriving (Generic)

Expand Down
11 changes: 6 additions & 5 deletions server/lib/api-tests/src/SpecHook.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ setupTestingMode = do
environment <- getEnvironment
lookupTestingMode environment `onLeft` error

hook :: HasCallStack => SpecWith GlobalTestEnvironment -> Spec
hook :: (HasCallStack) => SpecWith GlobalTestEnvironment -> Spec
hook specs = do
(testingMode, (logger, _cleanupLogger)) <-
runIO $
readIORef globalConfigRef `onNothingM` do
runIO
$ readIORef globalConfigRef
`onNothingM` do
testingMode <- setupTestingMode
(logger, cleanupLogger) <- setupLogger
setupGlobalConfig testingMode (logger, cleanupLogger)
Expand All @@ -134,8 +135,8 @@ hook specs = do
TestNoBackends -> True -- this is for catching "everything else"
TestNewPostgresVariant {} -> "Postgres" `elem` labels

aroundAllWith (const . bracket (setupTestEnvironment testingMode logger) teardownTestEnvironment) $
mapSpecForest (filterForestWithLabels shouldRunTest) (contextualizeLogger specs)
aroundAllWith (const . bracket (setupTestEnvironment testingMode logger) teardownTestEnvironment)
$ mapSpecForest (filterForestWithLabels shouldRunTest) (contextualizeLogger specs)

{-# NOINLINE globalConfigRef #-}
globalConfigRef :: IORef (Maybe (TestingMode, (Logger, IO ())))
Expand Down
8 changes: 4 additions & 4 deletions server/lib/api-tests/src/Test/API/ConcurrentBulkSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ postgresRunSqlQuery testEnvironment bulkType = do
let backendTypeMetadata = fromMaybe (error "Expected a backend type but got nothing") $ getBackendTypeConfig testEnvironment
sourceName = BackendType.backendSourceName backendTypeMetadata
backendPrefix = BackendType.backendTypeString backendTypeMetadata
postV2Query 200 testEnvironment $
[interpolateYaml|
postV2Query 200 testEnvironment
$ [interpolateYaml|
type: #{bulkType}
args:
- type: #{backendPrefix}_run_sql
Expand Down Expand Up @@ -153,8 +153,8 @@ mssqlRunSqlQuery testEnvironment bulkType = do
let backendTypeMetadata = fromMaybe (error "Expected a backend type but got nothing") $ getBackendTypeConfig testEnvironment
sourceName = BackendType.backendSourceName backendTypeMetadata
backendPrefix = BackendType.backendTypeString backendTypeMetadata
postV2Query 200 testEnvironment $
[interpolateYaml|
postV2Query 200 testEnvironment
$ [interpolateYaml|
type: #{bulkType}
args:
- type: #{backendPrefix}_run_sql
Expand Down
92 changes: 46 additions & 46 deletions server/lib/api-tests/src/Test/API/Metadata/ComputedFieldsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,52 +68,52 @@ setupFunctions :: TestEnvironment -> [Fixture.SetupAction]
setupFunctions testEnv =
let schemaName = Schema.getSchemaName testEnv
articleTableSQL = unSchemaName schemaName <> ".article"
in [ SetupAction.noTeardown $
BigQuery.run_ $
T.unpack $
T.unwords $
[ "CREATE TABLE FUNCTION ",
fetch_articles_returns_table schemaName,
"(a_id INT64, search STRING)",
"RETURNS TABLE<id INT64, title STRING, content STRING>",
"AS (",
"SELECT t.id, t.title, t.content FROM",
articleTableSQL,
"AS t WHERE t.author_id = a_id and (t.title LIKE `search` OR t.content LIKE `search`)",
");"
],
SetupAction.noTeardown $
BigQuery.run_ $
T.unpack $
T.unwords $
[ "CREATE TABLE FUNCTION ",
fetch_articles schemaName,
"(a_id INT64, search STRING)",
"AS (",
"SELECT t.* FROM",
articleTableSQL,
"AS t WHERE t.author_id = a_id and (t.title LIKE `search` OR t.content LIKE `search`)",
");"
],
SetupAction.noTeardown $
BigQuery.run_ $
T.unpack $
T.unwords $
[ "CREATE TABLE FUNCTION ",
function_no_args schemaName <> "()",
"AS (",
"SELECT t.* FROM",
articleTableSQL,
"AS t);"
],
SetupAction.noTeardown $
BigQuery.run_ $
T.unpack $
T.unwords $
[ "CREATE FUNCTION ",
add_int schemaName <> "(a INT64, b INT64)",
"RETURNS INT64 AS (a + b);"
]
in [ SetupAction.noTeardown
$ BigQuery.run_
$ T.unpack
$ T.unwords
$ [ "CREATE TABLE FUNCTION ",
fetch_articles_returns_table schemaName,
"(a_id INT64, search STRING)",
"RETURNS TABLE<id INT64, title STRING, content STRING>",
"AS (",
"SELECT t.id, t.title, t.content FROM",
articleTableSQL,
"AS t WHERE t.author_id = a_id and (t.title LIKE `search` OR t.content LIKE `search`)",
");"
],
SetupAction.noTeardown
$ BigQuery.run_
$ T.unpack
$ T.unwords
$ [ "CREATE TABLE FUNCTION ",
fetch_articles schemaName,
"(a_id INT64, search STRING)",
"AS (",
"SELECT t.* FROM",
articleTableSQL,
"AS t WHERE t.author_id = a_id and (t.title LIKE `search` OR t.content LIKE `search`)",
");"
],
SetupAction.noTeardown
$ BigQuery.run_
$ T.unpack
$ T.unwords
$ [ "CREATE TABLE FUNCTION ",
function_no_args schemaName <> "()",
"AS (",
"SELECT t.* FROM",
articleTableSQL,
"AS t);"
],
SetupAction.noTeardown
$ BigQuery.run_
$ T.unpack
$ T.unwords
$ [ "CREATE FUNCTION ",
add_int schemaName <> "(a INT64, b INT64)",
"RETURNS INT64 AS (a + b);"
]
]

fetch_articles_returns_table :: SchemaName -> T.Text
Expand Down
13 changes: 7 additions & 6 deletions server/lib/api-tests/src/Test/API/Metadata/TablesSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ spec = do
[ BigQuery.setupTablesAction schema testEnvironment
],
Fixture.customOptions =
Just $
Fixture.defaultOptions
Just
$ Fixture.defaultOptions
{ Fixture.stringifyNumbers = True
}
},
Expand Down Expand Up @@ -205,8 +205,9 @@ tests = do
|]
_ -> error "Unimplemented"

when (backendType == "sqlite") $
actual >>= \result -> result `shouldAtLeastBe` expected
when (backendType == "sqlite")
$ actual
>>= \result -> result `shouldAtLeastBe` expected

it "Returns null for an invalid table" \testEnvironment -> do
let backendTypeMetadata = fromMaybe (error "Unknown backend") $ getBackendTypeConfig testEnvironment
Expand All @@ -227,5 +228,5 @@ tests = do
- made_up_table
|]

when (backendType == "sqlite") $
shouldReturnYaml testEnvironment actual Null
when (backendType == "sqlite")
$ shouldReturnYaml testEnvironment actual Null
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ tests = do
it "does not include defaults on stand alone export" \testEnvironment -> do
response <- postMetadata testEnvironment exportMetadata
let response' = Object $ response CL.^. AL.key "metadata" . AL._Object & CL.sans "sources"
expected = [yaml| version: 3 |] -- Doesn't include defaults
expected = [yaml| version: 3 |]
-- Doesn't include defaults
response' `shouldBe` expected

describe "with metadata modifications" do
Expand All @@ -58,7 +59,8 @@ tests = do

response <- postMetadata testEnvironment exportMetadata
let response' = Object $ response CL.^. AL.key "metadata" . AL._Object & CL.sans "sources"
expected = [yaml| version: 3 |] -- Shouldn't include defaults
expected = [yaml| version: 3 |]
-- Shouldn't include defaults
response' `shouldBe` expected

exportMetadata :: Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ spec =
setupPermissionsAction permissions testEnv
],
Fixture.customOptions =
Just $
Fixture.defaultOptions
Just
$ Fixture.defaultOptions
{ Fixture.stringifyNumbers = True
}
},
Expand Down
27 changes: 14 additions & 13 deletions server/lib/api-tests/src/Test/DataConnector/MetadataApiSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ schemaInspectionTests = describe "Schema and Source Inspection" $ do
args:
name: *backendString
|]
) -- Note: These fields are backend specific so we ignore their values and just verify their shapes:
)
-- Note: These fields are backend specific so we ignore their values and just verify their shapes:
<&> Lens.set (key "config_schema_response" . key "other_schemas") J.Null
<&> Lens.set (key "config_schema_response" . key "config_schema") J.Null
<&> Lens.set (key "capabilities" . _Object . Lens.at "datasets") Nothing
Expand Down Expand Up @@ -403,10 +404,10 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
let capabilities = getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities
let foreignKeySupport = fromMaybe False $ capabilities ^? _Just . API.cDataSchema . API.dscSupportsForeignKeys
let relationshipsSupport = isJust $ capabilities ^? _Just . API.cRelationships . _Just
unless relationshipsSupport $
pendingWith "Backend does not support local relationships"
unless foreignKeySupport $
pendingWith "Backend does not support Foreign Key constraints"
unless relationshipsSupport
$ pendingWith "Backend does not support local relationships"
unless foreignKeySupport
$ pendingWith "Backend does not support Foreign Key constraints"

case (backendTypeString &&& backendSourceName) <$> getBackendTypeConfig testEnvironment of
Nothing -> pendingWith "Backend Type not found in testEnvironment"
Expand Down Expand Up @@ -439,10 +440,10 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
let capabilities = getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities
let foreignKeySupport = fromMaybe False $ capabilities ^? _Just . API.cDataSchema . API.dscSupportsForeignKeys
let relationshipsSupport = isJust $ capabilities ^? _Just . API.cRelationships . _Just
unless relationshipsSupport $
pendingWith "Backend does not support local relationships"
unless foreignKeySupport $
pendingWith "Backend does not support Foreign Key constraints"
unless relationshipsSupport
$ pendingWith "Backend does not support local relationships"
unless foreignKeySupport
$ pendingWith "Backend does not support Foreign Key constraints"

case (backendTypeString &&& backendSourceName) <$> TestEnvironment.getBackendTypeConfig testEnvironment of
Nothing -> pendingWith "Backend Type not found in testEnvironment"
Expand Down Expand Up @@ -539,10 +540,10 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
let capabilities = getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities
let foreignKeySupport = fromMaybe False $ capabilities ^? _Just . API.cDataSchema . API.dscSupportsForeignKeys
let relationshipsSupport = isJust $ capabilities ^? _Just . API.cRelationships . _Just
unless relationshipsSupport $
pendingWith "Backend does not support local relationships"
unless foreignKeySupport $
pendingWith "Backend does not support Foreign Key constraints"
unless relationshipsSupport
$ pendingWith "Backend does not support local relationships"
unless foreignKeySupport
$ pendingWith "Backend does not support Foreign Key constraints"

case (backendTypeString &&& backendSourceName) <$> TestEnvironment.getBackendTypeConfig testEnvironment of
Nothing -> pendingWith "Backend Type not found in testEnvironment"
Expand Down
Loading

0 comments on commit e0c0043

Please sign in to comment.