Skip to content

Conversation

@Aniruddh25
Copy link
Collaborator

@Aniruddh25 Aniruddh25 commented Mar 3, 2022

Summary

Today, FileMetadataProvider reads the runtime config file sql-config.json to get and populate DatabaseSchema object. This change implements a SqlMetadataProvider to read the same information from the database instead.

How

Tests

Added unit tests to verify the DatabaseSchema derived from the database matches what we expect from the runtime config file provider.

Future work:

  • To obtain foreign key information as well.
  • To use this MetadataProvider instead of the filemetadataprovider for the DatabaseSchema
  • To get ColumnType information
  • To separate this out into a library and reuse it in the GraphQL Schema Builder project

@junsu0ms
Copy link
Contributor

junsu0ms commented Mar 3, 2022

Both GetSchema and FillSchema are interface of ADO.NET. So it should work with MySQL/PGSQL?

@Aniruddh25
Copy link
Collaborator Author

Both GetSchema and FillSchema are interface of ADO.NET. So it should work with MySQL/PGSQL?

Thats what Im hoping for. Need to test it.

Copy link
Contributor

@seantleonard seantleonard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this! Looks good, just some clarifying questions and comments.

conn.ConnectionString = _connectionString;
await conn.OpenAsync();

DatabaseSchema.Tables.Clear();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this cause issues if requests come in between clearing the schema and re-populating it?

Copy link
Collaborator Author

@Aniruddh25 Aniruddh25 Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might, I have added this just envisioning we might need to support dynamic changes as per outcome of https://github.com/Azure/project-hawaii/issues/76
I think it might be reasonable to expect issues for a short period until we re-populate it if we decide to support the dynamic changes.

@Aniruddh25 Aniruddh25 dismissed aaronpowell’s stale review March 9, 2022 19:19

All the changes requested have been addressed. Merging it to unblock future development.

@Aniruddh25 Aniruddh25 merged commit 99996d4 into main Mar 9, 2022
@Aniruddh25 Aniruddh25 deleted the dev/anmunde/getDatabaseSchema branch March 9, 2022 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MsSql/PgSql: Infer schema from database to populate memory objects

5 participants