Skip to content
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

Table name collision bug fix #1990

Merged
merged 15 commits into from
Feb 28, 2024
Merged

Conversation

aaronburtle
Copy link
Contributor

@aaronburtle aaronburtle commented Jan 24, 2024

Why make this change?

Closes #1908

What is this change?

We were previously filling the schema information for the entity data set but only using the table name. We add in the schema name to deconflict between two tables with the same name in different schemas. This means that we retrieve information from the entity data set by using schema and tablename when schema is available, and just the table name otherwise.

The reason that we do not need to worry about collisions at the schema and table name level (eg. where we have the same schema and table names within different databases) is because this entity data set is a part of the SqlMetadataProvider, and we have a SqlMetadataProvider for each database (not database type but actual DBs).

How was this tested?

A regression test with a collision between table names in different schemas was added. We also update the unit test for SqlMetadatProvider.

Sample Request(s)

see #1908

Copy link
Contributor

@Aniruddh25 Aniruddh25 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 the quick fix! Need to make sure MySQL doesn't regress

Copy link
Contributor

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Need to reuse existing methods

Copy link
Contributor

@severussundar severussundar left a comment

Choose a reason for hiding this comment

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

Few things to consider:

  1. SourceDefinition class has a method called FullName which returns schemaName.tableName. A new method can be introduced that returns DBname.SchemaName.objectName.

Advantages with introducing this method
a) This would cover all database object types.
b) Logic of determining the full name would not get repeated at different places.
sourceDefinition.FullName() and sourceDefinition.FullNameIncludingDbName() (just example method name) can be used instead of determining the complete name multiple times.
3. This issue was reported for REST Get APIs. But, would be good to test this for other types like POST, PUT, etc.
4. This can be an opportunity to validate similar scenarios with GraphQL (This can be a separate issue/PR)

Copy link
Contributor

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Need to fix the test for databasename

Copy link
Contributor

@severussundar severussundar left a comment

Choose a reason for hiding this comment

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

LGTM, suggestions to validate few more scenarios as part of a different issue/PR.

  1. Validating and adding tests for the same bug but with views and stored procedures
  2. Validating and adding tests for the same bug with GraphQL

@aaronburtle
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@aaronburtle
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Contributor

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Needs to handle exceptions, and correct lookups

@Aniruddh25
Copy link
Contributor

Looks good to merge once unit tests succeed in pipeline and merged with main.

Copy link
Contributor

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Looks good to merge, tests that include database name in the connection string can be added optionally.

@aaronburtle
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@aaronburtle
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@aaronburtle
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@aaronburtle aaronburtle merged commit fa419cd into main Feb 28, 2024
9 checks passed
@aaronburtle aaronburtle deleted the dev/aaronburtle/TableNameCollisionFix branch February 28, 2024 04:15
seantleonard pushed a commit that referenced this pull request Mar 1, 2024
## Why make this change?

Closes #1908

## What is this change?

We were previously filling the schema information for the entity data
set but only using the table name. We add in the schema name to
deconflict between two tables with the same name in different schemas.
This means that we retrieve information from the entity data set by
using schema and tablename when schema is available, and just the table
name otherwise.

The reason that we do not need to worry about collisions at the schema
and table name level (eg. where we have the same schema and table names
within different databases) is because this entity data set is a part of
the SqlMetadataProvider, and we have a SqlMetadataProvider for each
database (not database type but actual DBs).

## How was this tested?

A regression test with a collision between table names in different
schemas was added. We also update the unit test for SqlMetadatProvider.

## Sample Request(s)

see #1908
seantleonard added a commit that referenced this pull request Mar 4, 2024
Cherry picks to `release/0.11` from `main`

## Why make this change?

Closes #1908

## What is this change?

We were previously filling the schema information for the entity data
set but only using the table name. We add in the schema name to
deconflict between two tables with the same name in different schemas.
This means that we retrieve information from the entity data set by
using schema and tablename when schema is available, and just the table
name otherwise.

The reason that we do not need to worry about collisions at the schema
and table name level (eg. where we have the same schema and table names
within different databases) is because this entity data set is a part of
the SqlMetadataProvider, and we have a SqlMetadataProvider for each
database (not database type but actual DBs).

## How was this tested?

A regression test with a collision between table names in different
schemas was added. We also update the unit test for SqlMetadatProvider.

Co-authored-by: aaronburtle <93220300+aaronburtle@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: DAB seems to have issues with tables in different schemas that have the same name (SQL Server)
5 participants