Disable Snowflake agent's relationships capability

[GDC-1189]: https://hasurahq.atlassian.net/browse/GDC-1189?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8934
GitOrigin-RevId: 2fa754f1a38b1b7c00ef1754354172f78eb18590
This commit is contained in:
Daniel Chambers 2023-05-09 11:14:18 +10:00 committed by hasura-bot
parent 54c6197ab7
commit 09d14cfc9d
2 changed files with 56 additions and 31 deletions

View File

@ -16,6 +16,7 @@ where
--------------------------------------------------------------------------------
import Control.Lens ((^?), _Just)
import Control.Lens qualified as Lens
import Data.Aeson qualified as J
import Data.Aeson.KeyMap qualified as KM
@ -355,7 +356,7 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
|]
describe "<kind>_track_table" $ do
it "success" $ \(testEnvironment, Chinook.ChinookTestEnv {nameFormatting = NameFormatting {..}}) -> do
it "success - track Album" $ \(testEnvironment, Chinook.ChinookTestEnv {nameFormatting = NameFormatting {..}}) -> do
case (backendTypeString &&& backendSourceName) <$> TestEnvironment.getBackendTypeConfig testEnvironment of
Nothing -> pendingWith "Backend Type not found in testEnvironment"
Just (backendType, sourceName) -> do
@ -376,28 +377,42 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
message: success
|]
describe "<kind>_create_object_relationship" $ do
it "success" $ \(testEnvironment@TestEnvironment {}, Chinook.ChinookTestEnv {nameFormatting = NameFormatting {..}}) -> do
let foreignKeySupport = (getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities) <&> API._dscSupportsForeignKeys . API._cDataSchema
case (backendTypeString &&& backendSourceName) <$> getBackendTypeConfig testEnvironment of
it "success - track Artist" $ \(testEnvironment, Chinook.ChinookTestEnv {nameFormatting = NameFormatting {..}}) -> do
case (backendTypeString &&& backendSourceName) <$> TestEnvironment.getBackendTypeConfig testEnvironment of
Nothing -> pendingWith "Backend Type not found in testEnvironment"
Just (backendType, sourceName) -> do
let actionType = backendType <> "_track_table"
artistTable = _nfFormatTableName ["Artist"]
albumTable = _nfFormatTableName ["Album"]
artistId = _nfFormatColumnName "ArtistId"
GraphqlEngine.postMetadata_
artist = _nfFormatTableName ["Artist"]
shouldReturnYaml
testEnvironment
( GraphqlEngine.postMetadata
testEnvironment
[yaml|
type: *actionType
args:
source: *sourceName
table: *artist
|]
)
[yaml|
type: *actionType
args:
source: *sourceName
table: *artistTable
|]
message: success
|]
when
(foreignKeySupport == Just False)
(pendingWith "Backend does not support Foreign Key constraints")
describe "<kind>_create_object_relationship" $ do
it "success" $ \(testEnvironment@TestEnvironment {}, Chinook.ChinookTestEnv {nameFormatting = NameFormatting {..}}) -> do
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"
case (backendTypeString &&& backendSourceName) <$> getBackendTypeConfig testEnvironment of
Nothing -> pendingWith "Backend Type not found in testEnvironment"
Just (backendType, sourceName) -> do
let albumTable = _nfFormatTableName ["Album"]
artistId = _nfFormatColumnName "ArtistId"
let createObjectRelationAction = backendType <> "_create_object_relationship"
shouldReturnYaml
@ -421,10 +436,14 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
describe "<kind>_create_array_relationship" $ do
it "success" $ \(testEnvironment@TestEnvironment {}, Chinook.ChinookTestEnv {nameFormatting = NameFormatting {..}}) -> do
let foreignKeySupport = (getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities) <&> API._dscSupportsForeignKeys . API._cDataSchema
when
(foreignKeySupport == Just False)
(pendingWith "Backend does not support Foreign Key constraints")
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"
case (backendTypeString &&& backendSourceName) <$> TestEnvironment.getBackendTypeConfig testEnvironment of
Nothing -> pendingWith "Backend Type not found in testEnvironment"
Just (backendType, sourceName) -> do
@ -458,7 +477,9 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
case ((fold . backendServerUrl) &&& backendTypeString &&& backendSourceName) <$> TestEnvironment.getBackendTypeConfig testEnvironment of
Nothing -> pendingWith "Backend Type not found in testEnvironment"
Just (agentUrl, (backendType, sourceName)) -> do
let foreignKeySupport = (getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities) <&> API._dscSupportsForeignKeys . API._cDataSchema
let capabilities = getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities
let foreignKeySupport = fromMaybe False $ capabilities ^? _Just . API.cDataSchema . API.dscSupportsForeignKeys
let relationshipsSupport = isJust $ capabilities ^? _Just . API.cRelationships . _Just
albumTable = _nfFormatTableName ["Album"]
artistTable = _nfFormatTableName ["Artist"]
artistId = _nfFormatColumnName "ArtistId"
@ -471,7 +492,7 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
args: {}
|]
)
if foreignKeySupport == Just True
if foreignKeySupport && relationshipsSupport
then
[yaml|
backend_configs:
@ -515,10 +536,14 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
describe "<kind>_drop_relationship" $ do
it "success" $ \(testEnvironment@TestEnvironment {}, Chinook.ChinookTestEnv {nameFormatting = NameFormatting {..}}) -> do
let foreignKeySupport = (getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities) <&> API._dscSupportsForeignKeys . API._cDataSchema
when
(foreignKeySupport == Just False)
(pendingWith "Backend does not support Foreign Key constraints")
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"
case (backendTypeString &&& backendSourceName) <$> TestEnvironment.getBackendTypeConfig testEnvironment of
Nothing -> pendingWith "Backend Type not found in testEnvironment"
Just (backendType, sourceName) -> do
@ -542,10 +567,6 @@ schemaCrudTests = describe "A series of actions to setup and teardown a source w
describe "<kind>_untrack_table" $ do
it "success" $ \(testEnvironment@TestEnvironment {}, Chinook.ChinookTestEnv {nameFormatting = NameFormatting {..}}) -> do
let foreignKeySupport = (getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities) <&> API._dscSupportsForeignKeys . API._cDataSchema
when
(foreignKeySupport == Just False)
(pendingWith "Backend does not support Foreign Key constraints")
case (backendTypeString &&& backendSourceName) <$> TestEnvironment.getBackendTypeConfig testEnvironment of
Nothing -> pendingWith "Backend Type not found in testEnvironment"
Just (backendType, sourceName) -> do

View File

@ -23,6 +23,9 @@ module Hasura.Backends.DataConnector.API.V0.Capabilities
cDatasets,
defaultCapabilities,
DataSchemaCapabilities (..),
dscSupportsPrimaryKeys,
dscSupportsForeignKeys,
dscColumnNullability,
defaultDataSchemaCapabilities,
ColumnNullability (..),
QueryCapabilities (..),
@ -560,3 +563,4 @@ instance HasCodec Licensing where
$(makeLenses ''CapabilitiesResponse)
$(makeLenses ''Capabilities)
$(makeLenses ''QueryCapabilities)
$(makeLenses ''DataSchemaCapabilities)