server: fix replace configuration in add source metadata API

>

### Description
>

### Changelog

- [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label.

### Affected components

- [x] Server

### Related Issues
->
Fixes #1528

### Solution and Design
>
Only replace connection configuration instead of replacing entire metadata with empty one.

GitOrigin-RevId: f9a16dcc7b1219ec1af915bf083622fcb7dde69a
This commit is contained in:
Rakesh Emmadi 2021-06-09 17:42:25 +05:30 committed by hasura-bot
parent 8bfc56b7c4
commit 04e041b8cb
2 changed files with 6 additions and 4 deletions

View File

@ -4,6 +4,7 @@
### Bug fixes and improvements
(Add entries below in the order of server, console, cli, docs, others)
- server: fix add source API wiping out source's metadata when replace_configuration is true
- console: add foreign key CRUD functionality to ms sql server tables
- console: allow tracking of custom SQL functions having composite type (rowtype) input arguments
- console: allow input object presets in remote schema permissions
@ -18,7 +19,7 @@
- server: fix asymptotic performance of fetching from the event_log table
- console: add `pool_timeout`, `connection_lifetime` and `isolation_level` connection params to connect database form
- console: add check constraints and comments to MS SQL Server tables' read-only modify page
- console: add create table functionality for MS SQL Server
- console: add create table functionality for MS SQL Server
- console: update connect database form with SSL certificates
- console: add drop table functionality to MS SQL Server tables
- console: allow renaming data sources

View File

@ -46,13 +46,14 @@ runAddSource
=> AddSource b -> m EncJSON
runAddSource (AddSource name sourceConfig replaceConfiguration) = do
sources <- scSources <$> askSchemaCache
let sourceMetadata = mkSourceMetadata @b name sourceConfig
metadataModifier <- MetadataModifier <$>
if HM.member name sources then
if replaceConfiguration then pure $ metaSources.ix name .~ sourceMetadata
if replaceConfiguration then pure $ metaSources.ix name.toSourceMetadata @b.smConfiguration .~ sourceConfig
else throw400 AlreadyExists $ "source with name " <> name <<> " already exists"
else pure $ metaSources %~ OMap.insert name sourceMetadata
else do
let sourceMetadata = mkSourceMetadata @b name sourceConfig
pure $ metaSources %~ OMap.insert name sourceMetadata
buildSchemaCacheFor (MOSource name) metadataModifier
pure successMsg