-
Notifications
You must be signed in to change notification settings - Fork 11
Add relationship metadata API for creating table relationships #88
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
This PR adds comprehensive relationship metadata API support to the Dataverse SDK, enabling programmatic creation and management of table relationships through the Web API. The implementation follows a clean architecture with metadata models, a relationship operations mixin, and convenience helpers.
Changes:
- New metadata model types (LocalizedLabel, Label, CascadeConfiguration, AssociatedMenuConfiguration, LookupAttributeMetadata, OneToManyRelationshipMetadata, ManyToManyRelationshipMetadata) with serialization support
- Relationship CRUD operations via mixin pattern (_RelationshipOperationsMixin) integrated into _ODataClient
- Public API methods on DataverseClient for creating/deleting/querying relationships
- Convenience extension helper (create_lookup_field) for simplified lookup scenarios
- Comprehensive unit tests (60 total, 25 new for metadata types)
- Full working example demonstrating all relationship operations
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/PowerPlatform/Dataverse/models/metadata.py | New metadata model types with to_dict() serialization for Web API |
| src/PowerPlatform/Dataverse/models/init.py | Exports new metadata types |
| tests/unit/models/test_metadata.py | Comprehensive unit tests for all metadata classes |
| tests/unit/models/init.py | Test package initialization |
| src/PowerPlatform/Dataverse/data/_relationships.py | Relationship operations mixin with create/read/delete methods |
| src/PowerPlatform/Dataverse/data/_odata.py | Integration of relationship mixin into _ODataClient |
| src/PowerPlatform/Dataverse/client.py | Public API methods for relationship operations |
| src/PowerPlatform/Dataverse/extensions/relationships.py | Convenience helper for common lookup field scenarios |
| src/PowerPlatform/Dataverse/extensions/init.py | Exports create_lookup_field helper |
| examples/advanced/relationships.py | Complete working example demonstrating all features |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
we should probably update README too |
Good call, updated README. |
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
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
|
|
||
| @dataclass | ||
| class AssociatedMenuConfiguration: |
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.
How do you plan to keep these upto date with DV? Do they need regular maintenance to support any new ones?
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.
The plan here is to implement just the core subset of properties that we need for our SDK functionality rather than maintain total parity with the .NET definitions, and I don't think we expect that core functionality to change. We would need to stay aware in case there were any server side changes to these models though so we should be careful not to add more than we need (eg. AssociatedMenuConfiguration is not strictly necessary for adding relationships so I've removed it in the latest iteration).
884755f to
b07d2e9
Compare
- Add metadata dataclasses (LocalizedLabel, Label, CascadeConfiguration, AssociatedMenuConfiguration, LookupAttributeMetadata, OneToManyRelationshipMetadata, ManyToManyRelationshipMetadata) - Add _RelationshipOperationsMixin with create/get/delete operations - Add create_lookup_field() convenience method to DataverseClient - Add comprehensive unit tests for all new functionality - Add relationships.py example demonstrating the API Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
b07d2e9 to
c248495
Compare
- Move OData type constants to common/constants.py - Add input/output examples to metadata to_dict() docstrings - Remove .NET SDK references from _relationships.py docstrings - Add __all__ to models/__init__.py Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c248495 to
c9c97ad
Compare
- Revert emoji formatting changes in examples (file_upload, walkthrough, functional_testing, installation_example) - Revert pyproject.toml changes (keep claude skill installer) - Update README with only relationship-related changes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Aligns with _RelationshipOperationsMixin naming convention. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move cascade behavior string values ("Cascade", "NoCascade", "RemoveLink",
"Restrict") to constants.py per PR review feedback. Update CascadeConfiguration
to use these constants for its default values.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove the AssociatedMenuConfiguration class and related parameters from relationship metadata types. This is a niche UI customization that most users don't need, and can still be achieved via additional_properties. Changes: - Remove AssociatedMenuConfiguration class from metadata.py - Remove associated_menu_configuration from OneToManyRelationshipMetadata - Remove entity1/2_associated_menu_configuration from ManyToManyRelationshipMetadata - Update example and tests accordingly Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rename solution_unique_name parameter to solution (shorter, consistent) - Add keyword-only separator (*) for optional parameters - Update tests to use new parameter style Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
DataverseClientfor creating and managing table relationshipsChanges
New API Methods on DataverseClient
create_one_to_many_relationship(lookup, relationship)- Create 1:N relationships with lookup fieldscreate_many_to_many_relationship(relationship)- Create N:N relationships with intersect tablesget_relationship(schema_name)- Query relationship metadata by schema namedelete_relationship(relationship_id)- Delete relationships by metadata IDNew Metadata Types (
models/metadata.py)LookupAttributeMetadata- Lookup field configurationOneToManyRelationshipMetadata- 1:N relationship definitionManyToManyRelationshipMetadata- N:N relationship definitionCascadeConfiguration- Cascade behavior settingsAssociatedMenuConfiguration- Navigation menu optionsLabel/LocalizedLabel- Multi-language label supportExtension Helper (
extensions/relationships.py)create_lookup_field()- Simplified helper for common lookup scenariosArchitecture
_relationships.pymixin to keep_odata.pyfocusedadditional_propertiesfor extensibilityTest plan