-
Notifications
You must be signed in to change notification settings - Fork 290
Populate DatabaseSchema by reading it from database #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
bfaf9cc
Build ColumnInfo
Aniruddh25 c336d7a
Merge origin/main
Aniruddh25 fb1eded
First draft of reading metadata from database
Aniruddh25 f5e2418
Set a default value for testing
Aniruddh25 998c8b9
Merge remote-tracking branch 'origin/main' into dev/anmunde/getDataba…
Aniruddh25 3934f89
MsSqlMetadataProvider and unit tests
Aniruddh25 5e7bb1f
fix sql-config
Aniruddh25 0a64aa9
Remove columnInfo builder query
Aniruddh25 f6cb272
Fix formatting
Aniruddh25 c6cb554
Fix test for Cosmos
Aniruddh25 2a7ff88
Create DatabaseMetadataProvider only if its MsSql for now
Aniruddh25 1879eaf
Only if MsSql
Aniruddh25 7e8a26b
Merge remote-tracking branch 'origin/main' into dev/anmunde/getDataba…
Aniruddh25 84e126e
Fix error message
Aniruddh25 163a5e6
Specify resolver config file in the test appsettings.json so the cons…
Aniruddh25 58ed4fd
Update DataGateway.Service/Services/MsSqlMetadataProvider.cs
Aniruddh25 50db729
Fix review comments
Aniruddh25 ad01393
Merge branch 'dev/anmunde/getDatabaseSchema' of https://github.com/Az…
Aniruddh25 1864aa3
Remove integration table name in InitializeTestFixture
Aniruddh25 5010c90
Generalize MetadataProvider to PgSql and MySql
Aniruddh25 c3d0e29
Update DataGateway.Service/Services/MsSqlMetadataProvider.cs
Aniruddh25 081758d
Update DataGateway.Service/Services/MsSqlMetadataProvider.cs
Aniruddh25 abf351b
Update DataGateway.Service.Tests/SqlTests/MsSqlMetadataProviderTests.cs
Aniruddh25 3be1a18
Update DataGateway.Service.Tests/SqlTests/MsSqlMetadataProviderTests.cs
Aniruddh25 d902917
explicit string cast and async
Aniruddh25 361381e
Add metadata provider
Aniruddh25 6a8f639
Merge remote-tracking branch 'origin/main' into dev/anmunde/getDataba…
Aniruddh25 21f47ec
Use CollectionAssert
Aniruddh25 71de42d
Honor schemaName
Aniruddh25 1dd1386
Fix MySqlTest
Aniruddh25 f2aaeb9
Fix formatting
Aniruddh25 a4aa11e
Remove ArgumentException
Aniruddh25 2fec3ae
Revert "Remove ArgumentException"
Aniruddh25 7bf8ccd
Ignore same table name from different schema
Aniruddh25 6a0a739
Update DataGateway.Service/Services/FileMetadataStoreProvider.cs
Aniruddh25 32e9994
Update DataGateway.Service/Services/FileMetadataStoreProvider.cs
Aniruddh25 a914a9d
Remove nullable usage, new lines and consistent using
Aniruddh25 7e5e320
Use text
Aniruddh25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
DataGateway.Service.Tests/SqlTests/MsSqlMetadataProviderTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using System.Threading.Tasks; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| namespace Azure.DataGateway.Service.Tests.SqlTests | ||
| { | ||
| [TestClass, TestCategory(TestCategory.MSSQL)] | ||
| public class MsSqlMetadataProviderTests : SqlMetadataProviderTests | ||
| { | ||
| [ClassInitialize] | ||
| public static async Task InitializeTestFixture(TestContext context) | ||
| { | ||
| await InitializeTestFixture(context, TestCategory.MSSQL); | ||
| } | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
DataGateway.Service.Tests/SqlTests/MySqlMetadataProviderTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using System.Threading.Tasks; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| namespace Azure.DataGateway.Service.Tests.SqlTests | ||
| { | ||
| [TestClass, TestCategory(TestCategory.MYSQL)] | ||
| public class MySqlMetadataProviderTests : SqlMetadataProviderTests | ||
| { | ||
| [ClassInitialize] | ||
| public static async Task InitializeTestFixture(TestContext context) | ||
| { | ||
| await InitializeTestFixture(context, TestCategory.MYSQL); | ||
| } | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
DataGateway.Service.Tests/SqlTests/PostgreSqlMetadataProviderTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using System.Threading.Tasks; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| namespace Azure.DataGateway.Service.Tests.SqlTests | ||
| { | ||
| [TestClass, TestCategory(TestCategory.POSTGRESQL)] | ||
| public class PostgreSqlMetadataProviderTests : SqlMetadataProviderTests | ||
| { | ||
| [ClassInitialize] | ||
| public static async Task InitializeTestFixture(TestContext context) | ||
| { | ||
| await InitializeTestFixture(context, TestCategory.POSTGRESQL); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
DataGateway.Service.Tests/SqlTests/SqlMetadataProviderTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| using System.Threading.Tasks; | ||
| using Azure.DataGateway.Service.Models; | ||
| using Azure.DataGateway.Service.Services; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| namespace Azure.DataGateway.Service.Tests.SqlTests | ||
| { | ||
| [TestClass] | ||
| public abstract class SqlMetadataProviderTests : SqlTestBase | ||
| { | ||
| [TestMethod] | ||
| public async Task TestDerivedDatabaseSchemaIsValid() | ||
| { | ||
| ResolverConfig runtimeConfig = _metadataStoreProvider.GetResolvedConfig(); | ||
| DatabaseSchema expectedSchema = runtimeConfig.DatabaseSchema; | ||
| DatabaseSchema derivedDatabaseSchema = | ||
| await _sqlMetadataProvider.RefreshDatabaseSchemaWithTablesAsync(_defaultSchemaName); | ||
Aniruddh25 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| foreach ((string tableName, TableDefinition expectedTableDefinition) in expectedSchema.Tables) | ||
| { | ||
| TableDefinition actualTableDefinition; | ||
| Assert.IsTrue(derivedDatabaseSchema.Tables.TryGetValue(tableName, out actualTableDefinition), | ||
| $"Could not find table definition for table '{tableName}'"); | ||
|
|
||
| CollectionAssert.AreEqual( | ||
| expectedTableDefinition.PrimaryKey, | ||
| actualTableDefinition.PrimaryKey, | ||
| $"Did not find the expected primary keys for table {tableName}"); | ||
|
|
||
| foreach ((string columnName, ColumnDefinition expectedColumnDefinition) in expectedTableDefinition.Columns) | ||
| { | ||
| ColumnDefinition actualColumnDefinition; | ||
| Assert.IsTrue(actualTableDefinition.Columns.TryGetValue(columnName, out actualColumnDefinition), | ||
| $"Could not find column definition for column '{columnName}' of table '{tableName}'"); | ||
|
|
||
| Assert.AreEqual(expectedColumnDefinition.IsAutoGenerated, actualColumnDefinition.IsAutoGenerated); | ||
| Assert.AreEqual(expectedColumnDefinition.HasDefault, actualColumnDefinition.HasDefault, | ||
| $"Expected HasDefault property of column '{columnName}' of table '{tableName}' does not match actual."); | ||
| Assert.AreEqual(expectedColumnDefinition.IsNullable, actualColumnDefinition.IsNullable, | ||
| $"Expected IsNullable property of column '{columnName}' of table '{tableName}' does not match actual."); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: probably worth separate issue/discussion. If no body provided in request, we would for this case, not want to expose table columns. Probably a more generic: "Body empty. Missing required field(s),"