Skip to content

Conversation

@RubenCerna2079
Copy link
Contributor

@RubenCerna2079 RubenCerna2079 commented Jan 27, 2026

Why make this change?

What is this change?

  • IQueryBuilder & MsSqlQueryBuilder: Adds new function that builds the query that returns all of the tables that will be turned into entities.
  • SqlMetadataProvider & MsSqlMetadataProvider: Adds function that executes query and receives the information for all of the existing autoentities. The information that is received for each table is the schema, object, and entity name, an example of this would be dbo, book, dbo.book. The query also transforms the reserved words {schema} and {object} into the tables schema and object and returns it in the name.
  • SqlMetadataProviderUnitTests: Adds testing to ensure that the query returns the expected output.

How was this tested?

  • Integration Tests
  • Unit Tests
  • Manual Testing

@RubenCerna2079 RubenCerna2079 added this to the Jan 2026 milestone Jan 27, 2026
@RubenCerna2079 RubenCerna2079 self-assigned this Jan 27, 2026
@RubenCerna2079 RubenCerna2079 linked an issue Jan 27, 2026 that may be closed by this pull request
@RubenCerna2079 RubenCerna2079 changed the title Create and execute query for Autoentities Create and execute query to return tables and interpolated names for Autoentities Jan 27, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds MSSQL support for querying autoentities include/exclude patterns and interpolated entity names, and wires this into metadata initialization with unit test coverage.

Changes:

  • Added a new BuildGetAutoentitiesQuery API to the query builder abstraction and implemented it for MSSQL.
  • Added MSSQL metadata-provider methods to execute the autoentities query during initialization and expose results for tests.
  • Added unit tests intended to validate autoentities query output and fixed a typo in MsSqlQueryExecutor method name.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/Service.Tests/UnitTests/SqlMetadataProviderUnitTests.cs Adds unit test for autoentities query output (currently has correctness/compilation issues).
src/Core/Services/MetadataProviders/SqlMetadataProvider.cs Calls into autoentities generation during MSSQL initialization.
src/Core/Services/MetadataProviders/MsSqlMetadataProvider.cs Adds autoentities query execution hooks (currently discards results).
src/Core/Resolvers/MsSqlQueryExecutor.cs Fixes ConfigureMsSqlQueryExecutor method spelling.
src/Core/Resolvers/MsSqlQueryBuilder.cs Adds MSSQL T-SQL batch to fetch eligible tables and interpolated entity names (currently unsafe/invalid).
src/Core/Resolvers/IQueryBuilder.cs Adds new autoentities query builder API as a default interface method.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RubenCerna2079
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@anushakolan anushakolan self-assigned this Jan 28, 2026
@github-project-automation github-project-automation bot moved this from Todo to Review In Progress in Data API builder Jan 28, 2026
@RubenCerna2079
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

"exclude_patterns AS ( SELECT LTRIM(RTRIM(value)) AS pattern FROM STRING_SPLIT(ISNULL(@exclude_pattern, N''), N',') " +
"WHERE LTRIM(RTRIM(value)) <> N'' ), all_tables AS ( SELECT s.name AS schema_name, t.name AS object_name, s.name + N'.' " +
"+ t.name AS full_name, N'table' AS object_type, t.object_id FROM sys.tables AS t JOIN sys.schemas AS s ON t.schema_id = s.schema_id " +
"WHERE EXISTS ( SELECT 1 FROM sys.key_constraints AS kc WHERE kc.parent_object_id = t.object_id AND kc.type = 'PK' ) ), eligible_tables AS " +
Copy link
Collaborator

Choose a reason for hiding this comment

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

        WHERE EXISTS
        (
            SELECT 1
            FROM sys.key_constraints AS kc
            WHERE kc.parent_object_id = t.object_id
              AND kc.type = 'PK'
        )

this condition is going to select only those tables which have PK constraint defined on them. Is that our intention? I dont think this should be what we do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While I agree with you on this, I think we need to discuss it with @JerryNixon

@Aniruddh25 Aniruddh25 self-assigned this Jan 30, 2026
Copy link
Collaborator

@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 parameterize the executed query.

@RubenCerna2079
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@RubenCerna2079
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@RubenCerna2079
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@RubenCerna2079
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@RubenCerna2079
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

Query include & exclude properties for autoentities Add interpolation for schema/object

4 participants