mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
Allow pg_run_sql
as well as run_sql
to remove some string-bodging
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7465 GitOrigin-RevId: 754866121fbd631273ae00a2305c8ddbba286596
This commit is contained in:
parent
9a54849985
commit
64f79daa3f
@ -92,15 +92,12 @@ postgresRunSqlQuery :: TestEnvironment -> String -> IO Value
|
||||
postgresRunSqlQuery testEnvironment bulkType = do
|
||||
let backendTypeMetadata = fromMaybe (error "Expected a backend type but got nothing") $ getBackendTypeConfig testEnvironment
|
||||
sourceName = BackendType.backendSourceName backendTypeMetadata
|
||||
backendPrefix =
|
||||
case BackendType.backendTypeString backendTypeMetadata of
|
||||
"pg" -> ""
|
||||
x -> x <> "_"
|
||||
backendPrefix = BackendType.backendTypeString backendTypeMetadata
|
||||
postV2Query 200 testEnvironment $
|
||||
[interpolateYaml|
|
||||
type: #{bulkType}
|
||||
args:
|
||||
- type: #{backendPrefix}run_sql
|
||||
- type: #{backendPrefix}_run_sql
|
||||
args:
|
||||
cascade: false
|
||||
read_only: true
|
||||
@ -108,7 +105,7 @@ postgresRunSqlQuery testEnvironment bulkType = do
|
||||
sql: |
|
||||
SELECT column_name, table_name, is_generated, is_identity, identity_generation
|
||||
FROM information_schema.columns where table_schema = 'public';
|
||||
- type: #{backendPrefix}run_sql
|
||||
- type: #{backendPrefix}_run_sql
|
||||
args:
|
||||
cascade: false
|
||||
read_only: true
|
||||
@ -116,7 +113,7 @@ postgresRunSqlQuery testEnvironment bulkType = do
|
||||
sql: |
|
||||
SELECT is_identity
|
||||
FROM information_schema.columns where table_schema = 'public';
|
||||
- type: #{backendPrefix}run_sql
|
||||
- type: #{backendPrefix}_run_sql
|
||||
args:
|
||||
cascade: false
|
||||
read_only: true
|
||||
@ -124,7 +121,7 @@ postgresRunSqlQuery testEnvironment bulkType = do
|
||||
sql: |
|
||||
SELECT column_name, table_name
|
||||
FROM information_schema.columns where table_schema = 'public';
|
||||
- type: #{backendPrefix}run_sql
|
||||
- type: #{backendPrefix}_run_sql
|
||||
args:
|
||||
cascade: false
|
||||
read_only: true
|
||||
@ -138,17 +135,14 @@ runSqlDrop :: TestEnvironment -> IO Value
|
||||
runSqlDrop testEnvironment = do
|
||||
let backendTypeMetadata = fromMaybe (error "Expected a backend type but got nothing") $ getBackendTypeConfig testEnvironment
|
||||
sourceName = BackendType.backendSourceName backendTypeMetadata
|
||||
backendPrefix =
|
||||
case BackendType.backendTypeString backendTypeMetadata of
|
||||
"pg" -> ""
|
||||
x -> x <> "_"
|
||||
backendPrefix = BackendType.backendTypeString backendTypeMetadata
|
||||
postV2Query
|
||||
500
|
||||
testEnvironment
|
||||
[interpolateYaml|
|
||||
type: concurrent_bulk
|
||||
args:
|
||||
- type: #{backendPrefix}run_sql
|
||||
- type: #{backendPrefix}_run_sql
|
||||
args:
|
||||
cascade: false
|
||||
read_only: false
|
||||
@ -161,15 +155,12 @@ mssqlRunSqlQuery :: TestEnvironment -> String -> IO Value
|
||||
mssqlRunSqlQuery testEnvironment bulkType = do
|
||||
let backendTypeMetadata = fromMaybe (error "Expected a backend type but got nothing") $ getBackendTypeConfig testEnvironment
|
||||
sourceName = BackendType.backendSourceName backendTypeMetadata
|
||||
backendPrefix =
|
||||
case BackendType.backendTypeString backendTypeMetadata of
|
||||
"pg" -> ""
|
||||
x -> x <> "_"
|
||||
backendPrefix = BackendType.backendTypeString backendTypeMetadata
|
||||
postV2Query 200 testEnvironment $
|
||||
[interpolateYaml|
|
||||
type: #{bulkType}
|
||||
args:
|
||||
- type: #{backendPrefix}run_sql
|
||||
- type: #{backendPrefix}_run_sql
|
||||
args:
|
||||
cascade: false
|
||||
read_only: true
|
||||
@ -183,7 +174,7 @@ mssqlRunSqlQuery testEnvironment bulkType = do
|
||||
'db_datareader', 'db_denydatawriter', 'db_denydatareader', 'hdb_catalog'
|
||||
)
|
||||
ORDER BY s.name;
|
||||
- type: #{backendPrefix}run_sql
|
||||
- type: #{backendPrefix}_run_sql
|
||||
args:
|
||||
cascade: false
|
||||
read_only: true
|
||||
@ -198,7 +189,7 @@ mssqlRunSqlQuery testEnvironment bulkType = do
|
||||
'db_datareader', 'db_denydatawriter', 'db_denydatareader', 'hdb_catalog'
|
||||
)
|
||||
ORDER BY s.name;
|
||||
- type: #{backendPrefix}run_sql
|
||||
- type: #{backendPrefix}_run_sql
|
||||
args:
|
||||
cascade: false
|
||||
read_only: true
|
||||
@ -211,7 +202,7 @@ mssqlRunSqlQuery testEnvironment bulkType = do
|
||||
'guest', 'INFORMATION_SCHEMA', 'sys'
|
||||
)
|
||||
ORDER BY s.name;
|
||||
- type: #{backendPrefix}run_sql
|
||||
- type: #{backendPrefix}_run_sql
|
||||
args:
|
||||
cascade: false
|
||||
read_only: true
|
||||
|
@ -653,10 +653,8 @@ untrackRelationships Table {tableName, tableReferences, tableManualRelationships
|
||||
runSQL :: HasCallStack => String -> String -> TestEnvironment -> IO ()
|
||||
runSQL source sql testEnvironment = do
|
||||
let backendTypeMetadata = fromMaybe (error "Unknown backend") $ getBackendTypeConfig testEnvironment
|
||||
prefix = case BackendType.backendType backendTypeMetadata of
|
||||
BackendType.Postgres -> ""
|
||||
_ -> BackendType.backendTypeString backendTypeMetadata <> "_"
|
||||
requestType = prefix <> "run_sql"
|
||||
prefix = BackendType.backendTypeString backendTypeMetadata
|
||||
requestType = prefix <> "_run_sql"
|
||||
GraphqlEngine.postV2Query_
|
||||
testEnvironment
|
||||
[yaml|
|
||||
|
@ -86,7 +86,10 @@ instance FromJSON RQLQuery where
|
||||
"update" -> RQUpdate <$> args
|
||||
"delete" -> RQDelete <$> args
|
||||
"count" -> RQCount <$> args
|
||||
-- Optionally, we can specify a `pg_` prefix. This primarily makes some
|
||||
-- string interpolation easier in the cross-backend tests.
|
||||
"run_sql" -> RQRunSql <$> args
|
||||
"pg_run_sql" -> RQRunSql <$> args
|
||||
"mssql_run_sql" -> RQMssqlRunSql <$> args
|
||||
"citus_run_sql" -> RQCitusRunSql <$> args
|
||||
"cockroach_run_sql" -> RQCockroachRunSql <$> args
|
||||
|
Loading…
Reference in New Issue
Block a user