Skip to content

Commit

Permalink
Fix DataSourceName update for HotReload (#2401)
Browse files Browse the repository at this point in the history
## Why make this change?

the correct way of updating the dataSourceName was already there in the
initial PR here:
https://github.com/Azure/data-api-builder/blob/741865371911ef0b8dc6a27d9bc9ef82470cfc16/src/Config/ObjectModel/RuntimeConfig.cs#L303
 
then in another refactor PR, it was incorrectly updated, ref:
https://github.com/Azure/data-api-builder/pull/2356/files#r1781334859

The current code directly assigns a new value to
`DefaultDataSourceName`. However, this approach does not account for
updating the different mappings related to DataSourceName when the
application undergoes a hot reload. During a hot reload, it is crucial
to maintain the same default data source name as before the hot reload
to all the mappings for being consistent. This is because references to
the data source depend on this name for lookups.

The new method `UpdateDefaultDataSourceName` ensures that the default
data source name is updated correctly, maintaining consistency across
hot reloads.

## What is this change?

- Using the correct initial method to update the DataSourceName for
HotReload Scenario.

## How was this tested?

- Manual Testing
- More tests should be a part of other HotReload PRs

Co-authored-by: Sean Leonard <[email protected]>
  • Loading branch information
abhishekkumams and seantleonard authored Oct 15, 2024
1 parent d9fd18c commit f97aa96
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Config/FileSystemRuntimeConfigLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public bool TryLoadConfig(

if (!string.IsNullOrEmpty(defaultDataSourceName))
{
RuntimeConfig.DefaultDataSourceName = defaultDataSourceName;
RuntimeConfig.UpdateDefaultDataSourceName(defaultDataSourceName);
}

config = RuntimeConfig;
Expand Down

0 comments on commit f97aa96

Please sign in to comment.