-
Notifications
You must be signed in to change notification settings - Fork 301
Create and execute query to return tables and interpolated names for Autoentities #3082
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
base: main
Are you sure you want to change the base?
Conversation
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.
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
BuildGetAutoentitiesQueryAPI 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
MsSqlQueryExecutormethod 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.
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
/azp run |
|
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 " + |
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.
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.
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.
While I agree with you on this, I think we need to discuss it with @JerryNixon
Aniruddh25
left a comment
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.
Need to parameterize the executed query.
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
Why make this change?
include&excludeproperties for autoentities #2966We need to create a query and send it to the database in order to receive all of the tables that will be turned into entities from the autoentities configuration. This includes the
schema,object, andentity name.What is this change?
schema,object, andentity name, an example of this would bedbo,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.How was this tested?