Add relationship support for entities of object type view
#3093
+102
−52
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.
Why make this change?
Closes #2780
DAB currently supports relationships only between table entities. This extends relationship support to views, enabling:
What is this change?
Extends relationship metadata processing and join predicate generation to work with view-backed entities.
Key changes:
database-typeismssqlordwsql. Stored procedures remain unsupported.ProcessRelationshipsnow acceptsDatabaseObjectinstead ofDatabaseTableDatabaseVieworDatabaseTablebased on target entity'ssource.typeDatabaseTableinternally forRelationShipPairserialization compatibilityVerifyForeignKeyExistsInDBsignature to acceptDatabaseObjectDesign notes:
RelationShipPairkeepsDatabaseTableproperties for serialization. Works becauseDatabaseObject.Equalscompares only schema+name, not type.Config example (view → table):
How was this tested?
208 config validation tests, 72 schema converter tests, 18 serialization tests pass. CodeQL: no alerts.
Sample Request(s)
GraphQL query traversing view → table relationship:
{ booksViews { items { title publisher { # Relationship field to table entity name } } } }Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
management.azure.com/usr/bin/pwsh pwsh -NoProfile -NonInteractive -EncodedCommand DQAKACQARQByAHIAbwByAEEAYwB0AGkAbwBuAFAAcgBlAGYAZQByAGUAbgBjAGUAIAA9ACAAJwBTAHQAbwBwACcADQAKAFsAdgBlAHIAcwBpAG8AbgBdACQAbQBpAG4AaQBtAHUAbQBWAGUAcgBzAGkAbwBuACAAPQAgACcAMgAuADIALgAwACcADQAKAA0ACgAkAG0AIAA9ACAASQBtAHAAbwByAHQALQBNAG8AZAB1AGwAZQAgAEEAegAuAEE(dns block)test/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/Azure.DataApiBuilder.Service.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/Azure.DataApiBuilder.Service.Tests.deps.json /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/testhost.dll --port 45391 --endpoint 127.0.0.1:045391 --role client --parentprocessid 6030 --telemetryoptedin false(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
view. #3079💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.